﻿#include "DrawWave.h"

CDrawWave::CDrawWave()
{
	m_pData = CDTData::GetInstance();
	m_rtWave = 0;
	m_enWaveBack = Normal_Wave;
	m_ptMouse = 0;
	m_vecReportRect.clear();
	m_rtAvgReport = 0;
//	m_nWaveReverse = 1;
	m_rtReturn = 0;
	m_rtReport = 0;
	m_dXGap = 0.0;
	m_dYGap = 0.0;
	m_dHfe = 0.0;
	m_nHPos = 0;
	m_nHPos2 = 0;
	m_nToLeft = 0;
	m_nPtLast = 0;
	m_ptLocatLine = 0;
	m_PtSec[0] = 0;
	m_PtSec[1] = 0; 
	m_dGap = 0.0;
	m_nDefectWD = 5;
	m_nSpeedPosUp = 0;
	m_nSpeedPosDown = 0;
	m_nPilePosUp = 0;
	m_nPilePosDown = 0;
	m_rtPile = 0;
	m_dXgpFreq = 0;
	m_nFrqAve = 0;
	m_nFrqPre = 0;
	m_nY = 0;
	for (int i = 0; i < 4; ++i)
	{
		m_rtTimeLine[i] = 0;
	}
	m_fPreFreq = 0.0;
	m_nT_PosX[4] = 0;
}
CDrawWave::~CDrawWave()
{

}

void CDrawWave::SetWaveRect(CRect rt, WAVE_BACK nWave, int nWaveCnt)
{
	m_rtWave = rt;
	m_enWaveBack = nWave;
}

void CDrawWave::SetWaveBack(CDC *pMemDc, BOOL bSel)
{
	CPen pen, *oldPen = NULL;
	if (m_enWaveBack == Ave_Wave || g_WaveStyle == WAVE_REPORT || g_WaveView == WAVE_FREQ || g_WaveView == WAVE_SINGLE)
	{
		pMemDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	}
	else if (m_enWaveBack == Normal_Wave)
	{
		pMemDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_NORAL_WAVE_BACK);
	}
	else{}
	pMemDc->SetBkMode(TRANSPARENT);
	pMemDc->SelectStockObject(NULL_BRUSH);
	pMemDc->SetBkMode(TRANSPARENT);
	if (bSel)
	{
//		pen.CreatePen(PS_SOLID, LEN_LINE, RGB(0, 0, 255));
		pen.CreatePen(PS_SOLID, LEN_LINE, COLOR_LINE);
		oldPen = pMemDc->SelectObject(&pen);
	}
	else
	{
		pen.CreatePen(PS_SOLID, LEN_LINE, COLOR_LINE);
		oldPen = pMemDc->SelectObject(&pen);
	}
	if (g_WaveView != WAVE_NORMAL)
	{
		pMemDc->Rectangle(m_rtWave);
	}
	
	pMemDc->SelectObject(oldPen);
	pen.DeleteObject();
}

void CDrawWave::SetReportBack(CDC *pMemDc, BOOL bSel)
{
	CPen pen, *oldPen = NULL;

	pMemDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);

	pMemDc->SetBkMode(TRANSPARENT);
	pMemDc->SelectStockObject(NULL_BRUSH);
	pMemDc->SetBkMode(TRANSPARENT);
	if (bSel)
	{
		pen.CreatePen(PS_SOLID, LEN_LINE, RGB(255, 0, 0));
		oldPen = pMemDc->SelectObject(&pen);
	}
	else
	{
		pen.CreatePen(PS_SOLID, LEN_LINE, COLOR_LINE);
		oldPen = pMemDc->SelectObject(&pen);
	}

	pMemDc->Rectangle(m_rtWave);

	pMemDc->SelectObject(oldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawReportWave(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int nCntNo, BOOL bSel)
{
	if (!m_pData->SelectPileOrNot() || (m_pData->m_vecReportNo.empty() && g_WaveView != WAVE_FREQ))
	{
		return;
	}
	SetReportBack(pMemDc, bSel);
	CRect rt = m_rtWave;
	if (nHamNo == AVG_WAVE_NO)
	{
		DrawWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, bSel);
	}
	else
	{
		DrawWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, bSel);
	}
	pDc->BitBlt(0, nCntNo * m_rtWave.Height(), rt.Width(), rt.Height(), pMemDc, 0, 0, SRCCOPY);
}

void CDrawWave::DrawOneWave(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int nCntNo, BOOL bSel)
{
	if (!m_pData->SelectPileOrNot())
	{
		return;
	}
	//如果是报告波形 则需要判断被用于报告的波形是否存在
	if (g_WaveStyle == WAVE_REPORT && m_pData->m_vecReportNo.empty())
	{
		return;
	}
	//背景色
	SetWaveBack(pMemDc, bSel);

	if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
	{
		DrawWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, bSel);
	}
	else
	{
		DrawWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, bSel);
	}

	pDc->BitBlt(0, nCntNo * m_rtWave.Height(), m_rtWave.Width(), m_rtWave.Height(), pMemDc, 0, 0, SRCCOPY);
}

//画报告的桩
void CDrawWave::DrawReportPile(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int nCntNo, int MoveState)
{
	if (!m_pData->SelectPileOrNot() || (m_pData->m_vecReportNo.empty() && g_WaveView != WAVE_FREQ))
	{
		return;
	}
	if (nHamNo == AVG_WAVE_NO)
	{
		DrawPile(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, MoveState);
	}
	else
	{
		DrawPile(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, MoveState);
	}
	pDc->TransparentBlt(0, nCntNo * m_rtWave.Height(), m_rtWave.Width(), m_rtWave.Height(),
		pMemDc, 0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
}

//画频域分析波形
void CDrawWave::DrawFreqDownWave(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int MoveState, int FrqADD, BOOL bReCale)
{
	if (!m_pData->SelectPileOrNot())
	{
		return;
	}
	if (g_WaveStyle == WAVE_REPORT && m_pData->m_vecReportNo.empty())
	{
		return;
	}
	if (g_WaveView == WAVE_FREQ)
	{
		SetReportBack(pMemDc, FALSE);
		if (nHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			if (bReCale)
			{	//重新计算频率波形数据
				m_pData->GetFreqData(m_pData->m_SpeedDataAvg[0][nPileNo], m_pData->m_FreqDataAvg[0][nPileNo], m_pData->m_vecPile.at(nPileNo).sDataCnt
					,nPileNo, AVG_WAVE_NO, 0, m_dYGap, m_dHfe);

				int nPosCnt = GetScreenWid(m_pData->m_vecPile.at(nPileNo), m_pData->m_vecAvgHam.at(nPileNo));
//				m_pData->GetFreqMax(m_pData->m_FreqDataAvg[0][nPileNo], m_pData->m_vecAvgHam.at(nPileNo).nWaveFMaxPos[0], m_pData->m_vecPile.at(nPileNo).sDataCnt);
				m_pData->GetFreqMax(m_pData->m_FreqDataAvg[0][nPileNo], m_pData->m_vecAvgHam.at(nPileNo).nWaveFMaxPos[0], nPosCnt);
				if (g_FileType == FILE_DOUBLE_SPEED)
				{
					m_pData->GetFreqData(m_pData->m_SpeedDataAvg[1][nPileNo], m_pData->m_FreqDataAvg[1][nPileNo], m_pData->m_vecPile.at(nPileNo).sDataCnt
						, nPileNo, AVG_WAVE_NO, 1, m_dYGap, m_dHfe);
					m_pData->GetFreqMax(m_pData->m_FreqDataAvg[1][nPileNo], m_pData->m_vecAvgHam.at(nPileNo).nWaveFMaxPos[1], nPosCnt);
				}
			}
			DrawFreqWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
				m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, MoveState, FrqADD);
		}
		else
		{
			if (bReCale)
			{
				m_pData->GetFreqData(m_pData->m_SpeedData[0][nPileNo][nHamNo], m_pData->m_FreqData[0][nPileNo][nHamNo], m_pData->m_vecPile.at(nPileNo).sDataCnt, 
					nPileNo, nHamNo, 0, m_dYGap, m_dHfe);
				int nPosCnt = GetScreenWid(m_pData->m_vecPile.at(nPileNo), m_pData->m_vvecHam[nPileNo].at(nHamNo));
//				m_pData->GetFreqMax(m_pData->m_FreqData[0][nPileNo][nHamNo], m_pData->m_vvecHam[nPileNo].at(nHamNo).nWaveFMaxPos[0], m_pData->m_vecPile.at(nPileNo).sDataCnt);
				m_pData->GetFreqMax(m_pData->m_FreqData[0][nPileNo][nHamNo], m_pData->m_vvecHam[nPileNo].at(nHamNo).nWaveFMaxPos[0], nPosCnt);
				if (g_FileType == FILE_DOUBLE_SPEED)
				{
					m_pData->GetFreqData(m_pData->m_SpeedData[1][nPileNo][nHamNo], m_pData->m_FreqData[1][nPileNo][nHamNo], m_pData->m_vecPile.at(nPileNo).sDataCnt,
						nPileNo, nHamNo, 1, m_dYGap, m_dHfe);
					m_pData->GetFreqMax(m_pData->m_FreqData[1][nPileNo][nHamNo], m_pData->m_vvecHam[nPileNo].at(nHamNo).nWaveFMaxPos[1], nPosCnt);
				}
			}
			DrawFreqWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
				m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, MoveState, FrqADD);
		}
		pDc->BitBlt(0, m_rtFreqDwon.top, m_rtWave.Width(), m_rtWave.Height(), pMemDc, 0, 0, SRCCOPY);
	}
}

int CDrawWave::GetScreenWid(DT56_PILE_INFO Pile_Info, DT56_HAM_INFO &Ham_Info)
{
	int nToLeft = m_rtWave.Width() / 25;	//开始画位置距离左侧边框距离
	int nToTop = m_rtWave.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = m_rtWave.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白

	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
	double dXgp = dXGap * 8;  //间距在原来的基础上扩为8倍的像素  显示1/4

	CPoint pt = 0;
	pt.x = nToLeft;
	int nIdx = 0;
	for (nIdx = 1; nIdx < Pile_Info.sDataCnt; ++nIdx)
	{
		if (pt.x >= nToLeft + nH_Wid)
		{
			break;
		}
		pt.x = (long)(dXgp * nIdx + nToLeft);
	}
	return nIdx;
}

void CDrawWave::DrawFreqWave(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState, int FrqADD)
{
	WSDATA DataBuf = { 0 };
	WSDATA DataBuf1 = { 0 };
	//获取数据
	GetFreqDataBuf(DataBuf, nPileNo, nHamNo, 0);
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		GetFreqDataBuf(DataBuf1, nPileNo, nHamNo, 1);
	}
	CSize szFont;
	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	font.AssertValid();
	
	OldFont = pDc->SelectObject(&font);

	CString strText(L"");
	strText = L"100";
	szFont = pDc->GetTextExtent(strText);
	int nBottomH = szFont.cy + 5 + 3;		//坐标底部高度 用于写数字和画刻度的高度 刻度高度5

	int nHPos = 0; //一个水平值

	
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = m_rtWave.Width() / 25;	//开始画位置距离左侧边框距离 
	m_nToLeft = nToLeft;
	int nToTop = m_rtWave.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = m_rtWave.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度
	int nV_Hig = m_rtWave.Height() - nToTop - nBottomH;	//画坐标系的时候 坐标高度

	//X轴两点间距
//	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom) * 1.0);
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
	dXGap = nH_Wid / (Pile_Info.sDataCnt / 2.0);
	//m_dXGap = dXGap;
	
	double dXgp = dXGap /** 6*/;  //间距在原来的基础上扩为8倍的像素  显示1/4
	dXgp = dXGap * g_nFreqZoom;  
	m_dXgpFreq = dXgp;
	CPoint pt = 0;
	//画竖坐标线
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom;
	pDc->MoveTo(pt);
	pt.y = m_rtWave.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom - nBottomH;
	pDc->MoveTo(pt);
	pt.x = m_rtWave.left + nToLeft + nH_Wid + nToLeft;
	pDc->LineTo(pt);

	//画坐标和刻度
	int nSenFrq = g_nFrq[nFrq];		//频率
	//nFrqPre必须为float类型，不然会出错 qzg 2020.7.13
	float nFrqPre = (float)(nSenFrq / (Pile_Info.sDataCnt * 1.0)); // 频率/点数  每个点的频率  频率分辨率

//	int nFrqPre = nSenFrq / Pile_Info.sDataCnt; // 频率/点数  每个点的频率  频率分辨率
	m_nFrqPre = nFrqPre;
	int nCnt = int(nH_Wid / dXgp);	//多少个点数 
	int nStep = nH_Wid / 5;			//宽度分成5分

	int nFrqAve = int(nFrqPre * nCnt); //该坐标上的总频率
	int nFrq5 = int(nFrqPre * nCnt / 5); //分五段 每段的频率
	nFrqAve = int(nFrqAve / dXgp); //该坐标上每个间距的频率
	m_nFrqAve = nFrqAve;
	int nXLeft = 0;
	for (int i = 1; i < 6; ++i)
	{
		nXLeft = nToLeft + nStep * i;
		nXLeft = int((double)nFrq5 * i / nFrqPre * dXgp + nToLeft);
		pDc->MoveTo(nXLeft, pt.y);
		pDc->LineTo(nXLeft, pt.y + 5);
		strText.Format(L"%d", nFrq5 * i);
		szFont = pDc->GetTextExtent(strText);
		pDc->TextOutW(nXLeft - szFont.cx / 2, pt.y + 6, strText);
	}
	//横坐标单位 
	strText = L"Hz";
	pDc->TextOutW(nToLeft + nH_Wid + nToLeft, pt.y + 2, strText);

	pDc->TextOutW(nToLeft + nH_Wid + nToLeft, pt.y + 2, strText);
	
	//计算比例
	int nAxisZoom = Ham_Info.sVZoom;
	double dSize = 1.00;	//缩放比例
	double dMax = 0.0;
//	dMax = DataBuf[Ham_Info.nWaveFMaxPos[0]];
	dMax = DataBuf[Ham_Info.nWaveFMaxPos[0]];
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		dMax = DataBuf1[Ham_Info.nWaveFMaxPos[1]] > dMax ? DataBuf1[Ham_Info.nWaveFMaxPos[1]] : dMax;
	}

	if (dMax > nV_Hig)
	{
		dSize = (double)dMax / nV_Hig;
	}
	if (dSize <= 0)
	{
		dSize = 1.0;
	}
	double dHfe = pow(2, (nAxisZoom - 50) / 15.0);
	m_dYGap = dSize;
	m_dHfe = dHfe;
// 	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
// 	m_nHPos = nHPos;
	//绘制曲线1
	pen.CreatePen(PS_SOLID, 2, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	if (g_Freq_Wave == FREQ_V1 || g_Freq_Wave == FREQ_V1V2)
	{
		pt.x = nToLeft;
		pt.y = m_rtWave.bottom - nBottomH;
		pt.y = long(m_rtWave.bottom - nBottomH - DataBuf[0] / dSize * dHfe);
		pDc->MoveTo(pt);
		int nIdx = 0;
		for (nIdx = 1; nIdx < Pile_Info.sDataCnt; ++nIdx)
		{
			if (pt.x >= nToLeft + nH_Wid)
			{
				break;
			}
			pt.x = (long)(dXgp * nIdx + nToLeft);
			pt.y = long(m_rtWave.bottom - nBottomH - DataBuf[nIdx] / dSize * dHfe);
			pDc->LineTo(pt);
		}

		DrawFreqTop(pDc, Ham_Info, 0, nFrqPre, dXgp, nToTop, nToTop, nToLeft);
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	
	//绘制曲线2
	pen.CreatePen(PS_SOLID, 2, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	if (g_FileType == FILE_DOUBLE_SPEED && (g_Freq_Wave == FREQ_V2 || g_Freq_Wave == FREQ_V1V2))
	{
		pt.x = nToLeft;
		pt.y = m_rtWave.bottom - nBottomH;
		pt.y = long(m_rtWave.bottom - nBottomH - DataBuf1[0] / dSize * dHfe);
		pDc->MoveTo(pt);
		int nIdx = 0;
		for (nIdx = 1; nIdx < Pile_Info.sDataCnt; ++nIdx)
		{
			if (pt.x >= nToLeft + nH_Wid)
			{
				break;
			}
			pt.x = (long)(dXgp * nIdx + nToLeft);
			pt.y = long(m_rtWave.bottom - nBottomH - DataBuf1[nIdx] / dSize * dHfe);
			pDc->LineTo(pt);
		}
		DrawFreqTop(pDc, Ham_Info, 1, nFrqPre, dXgp, nToTop + 6 * 3 + 9 * szFont.cy, nToTop, nToLeft);
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//鼠标移动
	if (0 == MoveState)
	{
		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= m_rtWave.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, m_rtWave.bottom - nToTop);
			pDc->LineTo(m_ptMouse.x, m_rtWave.top + nToTop);

			strText.Format(L"F = %d", int(double((m_ptMouse.x - nToLeft + 1) / dXgp) * nFrqPre));
			pDc->TextOutW(m_ptMouse.x + 5, m_rtWave.top + nToTop * 2, strText);

			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}

	//频域分析
	CString strStrings = g_LoadString(L"DW_33");
	szFont = pDc->GetTextExtent(strStrings);
	pDc->TextOutW(nToLeft + nToLeft, m_rtWave.top + szFont.cy, strStrings);

	pDc->SelectObject(OldFont);
	font.DeleteObject();
}

void CDrawWave::DrawFreqTop(CDC *pDc, DT56_HAM_INFO Ham_Info, int nNo, float nFrqPre, double dXgp, int nToTop, int nToDown, int nToLeft)
{
	CPen pen, *OldPen = NULL;
	CString strText(L"");
	CSize szFont;
	strText = L"F2-F1=00000Hz";
	szFont = pDc->GetTextExtent(strText);
	CString strData(L"");
	//Fm值
	int nGaxp = 3; //间距
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		strData.Format(L"Fm%d=%dHz,", nNo + 1, int((Ham_Info.nWaveFMaxPos[nNo]) * nFrqPre));
		pDc->TextOutW(m_rtWave.Width() - szFont.cx * 3, nToTop + nGaxp, strData);

		strData.Format(L"F0=%dHz", (int)nFrqPre);
		pDc->TextOutW(m_rtWave.Width() - szFont.cx, nToTop + nGaxp, strData);
	}
	else
	{
		strData.Format(L"Fm=%dHz,", int((Ham_Info.nWaveFMaxPos[0]) * nFrqPre));
		pDc->TextOutW(m_rtWave.Width() - szFont.cx * 3, nToTop + nGaxp, strData);

		strData.Format(L"F0=%dHz", (int)nFrqPre);
		pDc->TextOutW(m_rtWave.Width() - szFont.cx * 2, nToTop + nGaxp, strData);
	}

	//对频率进行排序
	std::vector<int> vFreq;
	for (int i = 0; i < Ham_Info.chFrepTopCnt[nNo]; ++i)
	{
		if (vFreq.empty())
		{
			vFreq.push_back(Ham_Info.sFrepTopPos[nNo][i]);
		}
		else
		{
			BOOL bInsert = FALSE;;
			for (int j = 0; j < (int)vFreq.size(); ++j)
			{
				if (Ham_Info.sFrepTopPos[nNo][i] < vFreq.at(j))
				{
					vFreq.insert(vFreq.begin() + j, Ham_Info.sFrepTopPos[nNo][i]);
					bInsert = TRUE;
					break;
				}
			}
			if (!bInsert)
			{
				vFreq.push_back(Ham_Info.sFrepTopPos[nNo][i]);
			}
		}
	}
	int nHi_Gap = nToTop + 2 * nGaxp + szFont.cy;
	double dLen = 0;
	int nLenFrq = 0;
	int nLastLenFreq = 0;
	CSize szText;
	for (int i = 0; i < Ham_Info.chFrepTopCnt[nNo]; ++i)
	{
		if (0 == i)
		{
			strText.Format(L"F1=%dHz", vFreq.at(i));
			pDc->TextOutW(m_rtWave.Width() - szFont.cx * 3, nHi_Gap, strText);
		}
		else
		{
			nHi_Gap += (szFont.cy + nGaxp);
			strText.Format(L"F%d=%dHz", i + 1, vFreq.at(i));
			pDc->TextOutW(m_rtWave.Width() - szFont.cx * 3, nHi_Gap, strText);

			strText.Format(L"F%d-F%d=%dHz", i + 1, i, vFreq.at(i) - vFreq.at(i - 1));
			pDc->TextOutW(m_rtWave.Width() - szFont.cx * 2, nHi_Gap, strText);

			dLen = Ham_Info.nWaveSpeed / ((vFreq.at(i) - vFreq.at(i - 1)) * 2 * 1.0);
			strText.Format(L"H%d=%.02fm", i, dLen);
			pDc->TextOutW(m_rtWave.Width() - szFont.cx, nHi_Gap, strText);
		}
// 		pen.CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
// 		OldPen = pDc->SelectObject(&pen);
		nLenFrq = int((double)vFreq.at(i) / nFrqPre * dXgp + nToLeft);
		pDc->MoveTo(nLenFrq, m_rtWave.bottom - nToDown);
		pDc->LineTo(nLenFrq, m_rtWave.top + nToTop + szFont.cy * 3);
		int nYGap = nToTop + szFont.cy * 2;
		int nAddGap = szFont.cy * 2 + 2 * nGaxp;
		if (i > 0)
		{
			strData.Format(L"%dHz", vFreq.at(i) - vFreq.at(i - 1));
			szText = pDc->GetTextExtent(strData);
			if (nLenFrq - nLastLenFreq <= szText.cx)
			{
				pDc->TextOutW(nLastLenFreq, nYGap - szFont.cy - nGaxp + i * nAddGap, strData);
			}
			else
			{
				pDc->TextOutW(nLastLenFreq + (nLenFrq - nLastLenFreq - szText.cx) / 2, nYGap - szFont.cy - nGaxp + i * nAddGap, strData);
			}

			strData.Format(L"%.02fm", dLen);
			szText = pDc->GetTextExtent(strData);
			if (nLenFrq - nLastLenFreq <= szText.cx)
			{
				pDc->TextOutW(nLastLenFreq, nYGap + nGaxp + i * nAddGap, strData);
			}
			else
			{
				pDc->TextOutW(nLastLenFreq + (nLenFrq - nLastLenFreq - szText.cx) / 2, nYGap + nGaxp + i * nAddGap, strData);
			}

			pDc->MoveTo(nLastLenFreq, nYGap + i * nAddGap);
			pDc->LineTo(nLenFrq, nYGap + i * nAddGap);
		}

		nLastLenFreq = nLenFrq;
// 		pDc->SelectObject(OldPen);
// 		pen.DeleteObject();
	}
}

//画桩和刻度
void CDrawWave::DrawPile(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int nCntNo, int MoveState)
{
	if (!m_pData->SelectPileOrNot())
	{
		return;
	}
	//如果是报告波形 则判断报告波形存在不
	if (g_WaveStyle == WAVE_REPORT && m_pData->m_vecReportNo.empty())
	{
		return;
	}
	if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
	{
		DrawPile(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, MoveState);
	}
	else
	{
		DrawPile(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, MoveState);
	}
	
	pDc->TransparentBlt(0, nCntNo * m_rtWave.Height(), m_rtWave.Width(), m_rtWave.Height(),
		pMemDc, 0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
}

void CDrawWave::InitWaveRect(int &nToLeft, int &nToTop, int &nH_Wid, int &nV_Hig, CRect rtWave)
{
	nToLeft = rtWave.Width() / 25;
	nToTop = rtWave.Height() / 25;
	nH_Wid = rtWave.Width() - 4 * nToLeft;
	nV_Hig = rtWave.Height() - 2 * nToTop;
}

void CDrawWave::InitWaveRect(CRect &rtDraw, CRect &rtInfo, CRect rtWave)
{
	rtDraw.left = rtWave.left + rtWave.Width() / 25;
	rtDraw.top = rtWave.top + rtWave.Height() / 25;
	rtDraw.right = rtWave.right - rtWave.Width() / 25 * 3;
	rtDraw.bottom = rtWave.bottom - rtWave.Height() / 25;

	rtInfo = rtDraw;
	rtInfo.left = rtDraw.right + 1;
	rtInfo.right = rtWave.right - 1;
}

void CDrawWave::GetDrawRect(CRect &rtKedu, CRect &rtPile, CRect &rtDrawWave, CSize szNum, CRect rtDraw)
{
	//刻度区域 //两个字符的高度
	rtKedu = rtDraw;
	rtKedu.top = rtDraw.bottom - szNum.cy - szNum.cy / 5;

	//桩区域
	rtPile = rtDraw;
	rtPile.bottom = rtKedu.top;
	rtPile.top = rtPile.bottom - rtDraw.top * 2;
	//单波形 桩高度小点  qzg 屏蔽掉，不然常规分析和单波视图比较时，波形和桩比例对不上
// 	if (g_WaveView == WAVE_SINGLE)
// 	{
// 		rtPile.top = rtPile.bottom - rtDraw.top;
// 	}

	//波形区域
	rtDrawWave = rtDraw;
	rtDrawWave.bottom = rtPile.top - rtDraw.top;
	rtDrawWave.top = rtDraw.top;
}

//画报告按钮
void CDrawWave::DrawReportBtn(CDC *pDc, CRect &rtReport, CRect rtInfo, DT56_HAM_INFO Ham_Info)
{
	CString strStrings(L"");
	CString strReport = L"√报告";
	strReport = g_LoadString(L"DW_0");
	CSize szReport = pDc->GetTextExtent(strReport);
	//报告文字区域
	rtReport.right = rtInfo.right - rtInfo.Width() / 10;
	rtReport.left = rtReport.right - szReport.cx;
	rtReport.top = rtInfo.top + 1;
	rtReport.bottom = rtReport.top + szReport.cy;

	//左侧方框
	CRect rtRR;
	rtRR.right = rtReport.left - 2;
	rtRR.top = rtReport.top + rtReport.Height() / 6;
	rtRR.left = rtRR.right - rtReport.Height() * 5 / 6;
	rtRR.bottom = rtReport.bottom - rtReport.Height() / 6;
	pDc->Rectangle(rtRR);
	pDc->SetTextColor(RGB(0, 0, 0));

	//画√ 和写 文字 选择红色 未选中黑色
	if (1 == Ham_Info.chUsedByReport)
	{
		strStrings = g_LoadString(L"DW_1");
		pDc->SetTextColor(RGB(255, 0, 0));
		pDc->DrawText(L"√", rtRR, DT_TOP | DT_CENTER);
		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else
	{
		strStrings = g_LoadString(L"DW_1");
		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
	}
	rtReport.left = rtRR.left;
}

void CDrawWave::DrawBasicInfoText(CDC *pDc, CString strWrod, CRect rtWrod)
{
	pDc->TextOutW(rtWrod.left, rtWrod.top, strWrod);
	pDc->MoveTo(rtWrod.left, rtWrod.bottom);
	pDc->LineTo(rtWrod.right, rtWrod.bottom);
}

//信息区域 信息
void CDrawWave::DrawBasicInfo(CDC *pDc, CRect rtReport, CRect rtInfo, DT56_HAM_INFO Ham_Info, DT56_PILE_INFO Pile_Info)
{
	CPen pen, *OldPen = NULL;
	pen.CreatePen(PS_SOLID, 1, RGB(0,0,0));
	OldPen = pDc->SelectObject(&pen);

	CString strStrings(L"");
	CString strText(L"");
	int nTextHi = 7;
	int nTextGap = 1;
	CRect rtWord = 0;
	rtWord.left = rtInfo.left + rtInfo.Width() / 10;
	rtWord.right = rtReport.right;
	rtWord.top = rtReport.bottom + rtReport.Height();
	rtWord.bottom = rtWord.top + rtReport.Height() + nTextGap;
	int nHig = rtWord.Height();
	//桩长
	strStrings = g_LoadString(L"DW_2");
	strText.Format(L"%.02fm", Ham_Info.fPileLen);
	strText = strStrings + strText;
	DrawBasicInfoText(pDc, strText, rtWord);

	rtWord.top += rtReport.Height() / 2 + nHig;
	rtWord.bottom += rtReport.Height() / 2 + nHig;
	//波速
	strStrings = g_LoadString(L"DW_3");
	strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
	strText = strStrings + strText;
	DrawBasicInfoText(pDc, strText, rtWord);

	rtWord.top += rtReport.Height() / 2 + nHig;
	rtWord.bottom += rtReport.Height() / 2 + nHig;
	//指数放大
	strStrings = g_LoadString(L"DW_4");
	strText.Format(L"%d", Ham_Info.sExpEnlargeNum);
	strText = strStrings + strText;
	DrawBasicInfoText(pDc, strText, rtWord);

	rtWord.top += rtReport.Height() / 2 + nHig;
	rtWord.bottom += rtReport.Height() / 2 + nHig;
	//低通滤波
	strStrings = g_LoadString(L"DW_5");
	strText.Format(L"%d Hz", Ham_Info.nFilterLowFrq);
	strText = strStrings + strText;
	DrawBasicInfoText(pDc, strText, rtWord);

	rtWord.top += rtReport.Height() / 2 + nHig;
	rtWord.bottom += rtReport.Height() / 2 + nHig;
	//采样频率
	strStrings = g_LoadString(L"DW_6");
	strText.Format(L"%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
	strText = strStrings + strText;
	DrawBasicInfoText(pDc, strText, rtWord);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

//获取Y轴两点像素长度
void CDrawWave::GetYGap(double &dYGap, double &dHfe, int &nKeDuHig, double dYMax, CRect rtDrawWave, CRect rtPile, int nBaseLine, DT56_HAM_INFO &Ham_Info)
{
	if (nBaseLine + Ham_Info.nMove_YZoom < 5 * rtDrawWave.top)
	{
		Ham_Info.nMove_YZoom = 5 * rtDrawWave.top - nBaseLine;
	}

	if (dYMax > (rtPile.bottom - rtDrawWave.top) * 1.0 / 2)
	{
		dYGap = dYMax / ((rtPile.bottom - rtDrawWave.top)* 1.0 / 2);	//qzg 2020.8.6
	}

	dHfe = pow(2, (Ham_Info.sVZoom - 49 + Ham_Info.nMove_YZoom) / 15.0);

	nKeDuHig = (int)(dYMax / dYGap * dHfe);  //像素点数
	if (0 == nKeDuHig)
	{
		nKeDuHig = int(0.3617 * (rtPile.bottom - rtDrawWave.top));
	}
}

//获取起始点数
int CDrawWave::GetBeginPos(double dXGap, int nDrawWaveWid, DT56_HAM_INFO &Ham_Info)
{
	if (Ham_Info.sPileTopPos <= 0)
	{
		Ham_Info.sPileTopPos = 200;
	}

	int nHPos = 0;
	nHPos = int((Ham_Info.sPileTopPos * dXGap - nDrawWaveWid / 8) / dXGap);
	return nHPos;
}

//画桩序号
CRect CDrawWave::DrawPileNo(CDC *pDc, CRect rtDraw, DT56_HAM_INFO Ham_Info, DT56_PILE_INFO Pile_Info, int nHamNo, BOOL bSel)
{
	CString strText(L"Avg");
//	CString strText(L"平均波形");
	CSize szNo = pDc->GetTextExtent(strText);
	CRect rtNo = 0;
	rtNo.SetRect(rtDraw.left + 10, m_rtWave.top + 5, int(rtDraw.left + 10 + szNo.cx * 1.8), m_rtWave.top + 5 + szNo.cy + szNo.cy / 8);

	if (bSel || g_WaveView == WAVE_FREQ || g_WaveView == WAVE_NORMAL || g_WaveView == WAVE_SINGLE)
	{
		pDc->FillSolidRect(rtNo, RGB(255, 120, 120));
	}
	else
	{
		pDc->FillSolidRect(rtNo, RGB(180, 180, 180));
	}
	if (Ham_Info.sHamNum == AVG_WAVE_NO || nHamNo == AVG_WAVE_NO)
	{
		if (g_enLanguage == CHN)
		{
			strText.Format(L"平均");
		}
		else
		{
			strText.Format(L"Avg");
		}		
	}
	else
	{
		strText.Format(L"%d/%d", Ham_Info.sHamNum, Pile_Info.sHamCnts);
	}
	szNo = pDc->GetTextExtent(strText);
	pDc->TextOutW(rtNo.left + rtNo.Width() / 2 - szNo.cx / 2,
		rtNo.top + rtNo.Height() / 2 - szNo.cy / 2, strText);

	return rtNo;
}

//画纵坐标最大值
void CDrawWave::DrawMaxText(CDC *pDc, CRect rtDraw, int nBaseLine, double dMaxLen1, double dKeDu1, double dMaxLen2, double dKeDu2)
{
	CPen pen, *oldPen = NULL;
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	oldPen = pDc->SelectObject(&pen);

	CString strText(L"");
	dKeDu1 = Carry(dKeDu1, 2);
	strText.Format(L"%.02f", dKeDu1);
	CSize szText = pDc->GetTextExtent(L"(v1 max)");
	//画刻度线
	CPoint pt;
	pt.x = rtDraw.left;
	pt.y = long(nBaseLine - dMaxLen1);
	if (pt.y < rtDraw.top + szText.cy)
	{
		pt.y = long(rtDraw.top + szText.cy);
	}

	//qzg 屏蔽掉最大值刻度线 2020.8.6
// 	pDc->MoveTo(pt);
// 	pDc->LineTo(pt.x - 5, pt.y);
	//写刻度
	
	CRect rtText = 0;
	rtText.right = pt.x;
	rtText.left = rtText.right - szText.cx;
	rtText.top = pt.y - szText.cy / 2;
	rtText.bottom = rtText.top + szText.cy;
	pDc->SetTextColor(g_SysSet.Cuver1clr);
	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		strText = L"(v1 max)";
		szText = pDc->GetTextExtent(strText);
		rtText.left = pt.x - szText.cx - 1;
	}
	else
	{
		strText = L"(max)";
	}
	rtText.top += (szText.cy);
	rtText.bottom = rtText.top + szText.cy;

	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);

	pDc->SelectObject(oldPen);
	pen.DeleteObject();

	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		
		pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
		oldPen = pDc->SelectObject(&pen);
		pDc->SetTextColor(g_SysSet.Cuver2clr);
		//画刻度2
		dKeDu2 = Carry(dKeDu2, 2);
		strText.Format(L"%.02f", dKeDu2);
		//画刻度线
		pt.x = rtDraw.left;
		pt.y = long(nBaseLine - dMaxLen2);
		if (pt.y < rtDraw.top + szText.cy)
		{
			pt.y = long(rtDraw.top + szText.cy);
		}
		pDc->MoveTo(pt);
		pDc->LineTo(pt.x - 5, pt.y);
		//写刻度

		rtText.top += (szText.cy);
		rtText.bottom = rtText.top + szText.cy;
		pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
		strText = L"(v2 max)";
		szText = pDc->GetTextExtent(strText);
		rtText.left = pt.x - szText.cx - 1;
		rtText.top += (szText.cy);
		rtText.bottom = rtText.top + szText.cy;
		pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);

		pDc->SelectObject(oldPen);
		pen.DeleteObject();
	}
	pDc->SetTextColor(RGB(0,0,0));
}

void CDrawWave::DrawWaveLine(CDC *pDc, CRect rtDraw, WSDATA DataBuf, int nHBeginPos, int nBaseLine, double dXGap, double dYGap, double dHfe, int nCnts, COLORREF clr, VEC2_PT &ptFill)
{
	double dXSite = rtDraw.left;
	double dYSite = 0.0;
	CPoint pt = 0;

	CPen pen, *pOldPen = NULL;
	pen.CreatePen(PS_SOLID, 1, clr);
	pOldPen = pDc->SelectObject(&pen);

	//画波形
	int nCntFill = 0;
	VEC_PT ptFillOne;

	pt.x = (long)dXSite;
	if (nHBeginPos < 0)
	{
		pt.x = (long)(dXSite + abs(nHBeginPos) * dXGap);
		pt.y = (long)nBaseLine;
	}
	else
	{
		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf[nHBeginPos] / dYGap * dHfe);
	}
	
	pDc->MoveTo(pt);
	if (g_bBtnFillWave)
	{	//填充
		AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
	}
	for (int i = m_nHPos; i < nCnts; ++i)
	{
		if (dXSite >= rtDraw.right)
		{
			break;
		}
			
		if (i < 0)
		{
			dYSite = nBaseLine;
			dXSite += dXGap;
			continue;
		}
		else
		{
			dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe);
		}
		pt.x = (long)dXSite;
		pt.y = (long)dYSite;
		pDc->LineTo(pt);
		if (g_bBtnFillWave)
		{	//填充
			AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
		}
		dXSite += dXGap;
	}

	pDc->SelectObject(pOldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawWave(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, BOOL bSel)
{
	CString strStrings(L""); //专门用于中英文翻译的变量
	WSDATA DataBuf = { 0 };		//用于保存波形1数据
	WSDATA DataBuf1 = { 0 };	//用于保存波形2数据

	CFont font, *OldFont = NULL;
	//获取字体大小
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);
	CPen pen, *OldPen = NULL;				//定义画笔

	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率

	//计算一下一个数字的高度， 用于后面计算
	CString strNum = L"55";
	CSize szNum;
	szNum = pDc->GetOutputTextExtent(strNum);

	CString strText(L"");

	CRect rtDraw = 0;			//左侧画布区域
	CRect rtInfo = 0;			//右侧信息区域
	InitWaveRect(rtDraw, rtInfo, m_rtWave);
	m_nToLeft = rtDraw.left;

	CRect rtKedu = 0;			//横坐标画刻度区域
	CRect rtPile = 0;			//桩区域
	CRect rtDrawWave = 0;		//画波形区域
	//获取此区域大小
	GetDrawRect(rtKedu, rtPile, rtDrawWave, szNum, rtDraw);

	int nBaseLine = 0;			//波形基准线高度  qzg 2020.8.6
//	nBaseLine = rtDrawWave.top + rtDrawWave.Height() / 2;
	nBaseLine = rtDrawWave.top + (rtPile.bottom - rtDrawWave.top) / 2;

	//画报告按钮
	CRect rtReport;
	DrawReportBtn(pDc, rtReport, rtInfo, Ham_Info);
	m_rtReport = rtReport;
	pDc->SetTextColor(RGB(0, 0, 0));
	//保存报告区域
	if (m_enWaveBack == Ave_Wave)
	{
		m_rtAvgReport = rtReport;
	}
	else
	{
		CRect rtR = rtReport;
		rtR.top += nHamNo * m_rtWave.Height();
		rtR.bottom = rtR.top + rtReport.Height();
		if (nHamNo <= (int)m_vecReportRect.size() - 1)
		{
			m_vecReportRect.at(nHamNo) = rtR;
		}
		else
		{
			m_vecReportRect.push_back(rtR);
		}
	}
	//信息区域
	DrawBasicInfo(pDc, rtReport, rtInfo, Ham_Info, Pile_Info);
	//画序号
	CRect rtNo = DrawPileNo(pDc, rtDraw, Ham_Info, Pile_Info, nHamNo, bSel);
	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);

	double dYGap = 1.0;		//Y轴两点间距
	double dHfe = 1.0;		//Y轴缩放系数
	int nKeDuHig = 0;

	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	GetYGap(dYGap, dHfe, nKeDuHig, dMax, rtDrawWave, rtPile, nBaseLine, Ham_Info);
// 	//Y轴长度
// 	double dMaxLen = GetYLen(dMax, Pile_Info);
	//X轴两点间距
	double dXGap = GetXGap(rtDrawWave.Width(), Pile_Info, Ham_Info);
	//Y轴长度
	double dLen1 = GetYLen(dMax1, Pile_Info);
	double dLen2 = GetYLen(dMax2, Pile_Info);
	double dKeDu1 = GetKeDu(dLen1, dHfe, Pile_Info, 0);
	double dKeDu2 = GetKeDu(dLen2, dHfe, Pile_Info, 1);

	//起始点 可以为负数
	int nHPos = GetBeginPos(dXGap, rtDrawWave.Width(), Ham_Info);

	int nKeDuHig1 = 0;
	int nKeDuHig2 = 0;
	nKeDuHig1 = (int)(dMax1 / dYGap * dHfe);  //像素点数
	if (0 == nKeDuHig1)
	{
		nKeDuHig1 = int(0.3617 * (rtPile.bottom - rtDrawWave.top));
	}

	nKeDuHig2 = (int)(dMax2 / dYGap * dHfe);  //像素点数
	if (0 == nKeDuHig2)
	{
		nKeDuHig2 = int(0.3617 * (rtPile.bottom - rtDrawWave.top));
	}

	//画纵坐标最大值
	DrawMaxText(pDc, rtDraw, nBaseLine, nKeDuHig1, dKeDu1, nKeDuHig2, dKeDu2);

	//画波形
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		VEC2_PT ptFill;
		GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);
		DrawWaveLine(pDc, rtDraw, DataBuf, m_nHPos, nBaseLine, dXGap, dYGap, dHfe, Pile_Info.sDataCnt, g_SysSet.Cuver1clr, ptFill);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
		{	//填充波形
			DrawFillWave(pDc, ptFill);
		}
	}

	//画波形2
	m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
	if (g_FileType == FILE_DOUBLE_SPEED && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		VEC2_PT ptFill;
		GetDataBuf(DataBuf1, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 1);
		DrawWaveLine(pDc, rtDraw, DataBuf1, m_nHPos, nBaseLine, dXGap, dYGap, dHfe, Pile_Info.sDataCnt, g_SysSet.Cuver2clr, ptFill);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
		{	//填充波形
			DrawFillWave(pDc, ptFill);
		}
	}
	
	pDc->SelectObject(OldFont);
	font.DeleteObject();
}


void CDrawWave::DrawWave_1(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, BOOL bSel)
{
// 	DrawWave_1(pDc, Pile_Info, Ham_Info, nPileNo, nHamNo, bSel);
// 	return;
	/*
	CString strStrings(L""); //专门用于中英文翻译的变量
	WSDATA DataBuf = { 0 };
	WSDATA DataBuf1 = { 0 };0.0
	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);
	int nHPos = 0;
	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = m_rtWave.Width() / 25;	//开始画位置距离左侧边框距离 
	m_nToLeft = nToLeft;
	int nToTop = m_rtWave.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = m_rtWave.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = m_rtWave.Height() - 2 * nToTop;	//画坐标系的时候 坐标高度
	int nPileH = 3 * nToTop;					//桩的高度（宽度）
	if (g_WaveView == WAVE_SINGLE)
	{
		nPileH = nToTop;
	}
	int nWaveV_Hig = m_rtWave.Height() - nPileH - 6 * nToTop;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = 2 * nToTop + nWaveV_Hig / 2;		//基准线位置

	CRect rtReport = 0;
	CString strReport = L"√报告";
	strReport = g_LoadString(L"DW_0");
	CSize szReport = pDc->GetTextExtent(strReport);
	rtReport.right = m_rtWave.right - 20;
	rtReport.left = rtReport.right - szReport.cx;
	rtReport.top = m_rtWave.top + nToTop;
	rtReport.bottom = rtReport.top + szReport.cy;
	m_rtReport = rtReport;

	//左侧方框
	CRect rtRR;
	rtRR.right = rtReport.left - 2;
	rtRR.top = rtReport.top + rtReport.Height() / 6;
	rtRR.left = rtRR.right - rtReport.Height() * 5 / 6;
	rtRR.bottom = rtReport.bottom - rtReport.Height() / 6;
	pDc->Rectangle(rtRR);

	m_rtReport.left = rtRR.left;
	if (1 == Ham_Info.chUsedByReport)
	{
		strStrings = g_LoadString(L"DW_1");
		pDc->SetTextColor(RGB(255, 0, 0));
		pDc->DrawText(L"√", rtRR, DT_TOP | DT_CENTER);

		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
//		pDc->DrawText(L"√报告", rtReport, DT_TOP | DT_RIGHT);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else
	{
		strStrings = g_LoadString(L"DW_1");
		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
//		pDc->DrawText(L"报告", rtReport, DT_TOP | DT_RIGHT);
	}
	//保存报告区域
	
	if (m_enWaveBack == Ave_Wave)
	{
//		rtReport.bottom = rtReport.top + szReport.cy;
		m_rtAvgReport = rtReport;
		m_rtAvgReport.left = rtRR.left;
	}
	else
	{
		
		rtReport.top += nHamNo * m_rtWave.Height();
		rtReport.bottom = rtReport.top + szReport.cy;
		CRect rtR = rtReport;
		rtR.left = rtRR.left;
		if (nHamNo <= (int)m_vecReportRect.size() - 1)
		{
			m_vecReportRect.at(nHamNo) = rtR;
		}
		else
		{
			m_vecReportRect.push_back(rtR);
		}
	}

	int nTextHi = 7;
	int nTextGap = 1;
	CPoint ptWord = CPoint(m_rtWave.right - 3 * nToLeft + 10, int(m_rtWave.top + nToTop + szReport.cy * 1.5));
	strStrings = g_LoadString(L"DW_2");
	strText.Format(L"%.02fm", Ham_Info.fPileLen);
	strText = strStrings + strText;
//	strText.Format(L"桩长：%.02fm", Ham_Info.fPileLen);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + nTextGap);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += nTextHi;
	strStrings = g_LoadString(L"DW_3");
	strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
	strText = strStrings + strText;
//	strText.Format(L"波速：%dm/s", Ham_Info.nWaveSpeed);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + nTextGap);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += nTextHi;
	strStrings = g_LoadString(L"DW_4");
	strText.Format(L"%d", Ham_Info.sExpEnlargeNum);
	strText = strStrings + strText;
//	strText.Format(L"指数放大：%d", Ham_Info.sExpEnlargeNum);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + nTextGap);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += nTextHi;
	strStrings = g_LoadString(L"DW_5");
	strText.Format(L"%d Hz", Ham_Info.nFilterLowFrq);
	strText = strStrings + strText;
//	strText.Format(L"低通：%d Hz", Ham_Info.nFilterLowFrq);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + nTextGap);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += nTextHi;
	strStrings = g_LoadString(L"DW_6");
	strText.Format(L"%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
	strText = strStrings + strText;
//	strText.Format(L"采样频率：%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + nTextGap);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);


	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	double dMax = GetWaveMaxValue(Ham_Info);

	//Y轴两点间距
	double dYGap = 1.0;
	if (nBaseLine + Ham_Info.nMove_YZoom < 5 * nToTop)
	{
		Ham_Info.nMove_YZoom = 5 * nToTop - nBaseLine;
	}
	if (dMax >(nWaveV_Hig) * 1.0 / 2)
	{
		dYGap = dMax / ((nWaveV_Hig) * 1.0 / 2);
	}
	
	//X轴两点间距
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);

	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);

	//Y轴长度
	double dLen = GetYLen(dMax, Pile_Info);

// 	int nSite = (int)(dMax / dYGap);  //像素点数
// 	if (0 == nSite)
// 	{
// 		nSite = int(0.3617 * nWaveV_Hig);
// 	}
	double dHfe = pow(2, (Ham_Info.sVZoom - 49 + Ham_Info.nMove_YZoom) / 15.0);

	double dKeDu = GetKeDu(dLen, dHfe, Pile_Info);

	//桩序号
	CRect rtNo;
	rtNo = CRect(m_rtWave.left + nToLeft + 10, m_rtWave.top + 5,
		m_rtWave.left + nToLeft + 50, m_rtWave.top + 23);
	if (bSel || g_WaveView == WAVE_FREQ || g_WaveView == WAVE_NORMAL || g_WaveView == WAVE_SINGLE)
	{
		pDc->FillSolidRect(rtNo, RGB(255, 120, 120));
	}
	else
	{
		pDc->FillSolidRect(rtNo, RGB(180, 180, 180));
	}
	if (Ham_Info.sHamNum == AVG_WAVE_NO || nHamNo == AVG_WAVE_NO)
	{
		strText.Format(L"Avg");
	}
	else
	{
		strText.Format(L"%d/%d", Ham_Info.sHamNum, Pile_Info.sHamCnts);
	}
	
	CSize szNo = pDc->GetTextExtent(strText);
	pDc->TextOutW(rtNo.left + rtNo.Width() / 2 - szNo.cx / 2,
		rtNo.top + rtNo.Height() / 2 - szNo.cy / 2, strText);

	CPoint pt;
	pt.x = m_rtWave.left + nToLeft;
	pt.y = long(nBaseLine - dLen);
	pDc->MoveTo(pt);
	pDc->LineTo(pt.x - 5, pt.y);
	
	strText.Format(L"%.02f", dKeDu);
	CSize szText = pDc->GetTextExtent(strText);
	CRect rtText =0;
	rtText.right = pt.x - 10;
	rtText.left = rtText.right - szText.cx;
	rtText.top = pt.y - szText.cy / 2;
	rtText.bottom = rtText.top + szText.cy;
	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
	strText = L"(max)";
	rtText.top += (szText.cy);
	rtText.bottom = rtText.top + szText.cy;
	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
	//绘制曲线
	
	double dXSite = nToLeft;
	double dYSite = 0.0;
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		GetDataBuf(DataBuf1, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 1);
	}

// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
//	m_nHPos = nHPos;
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	//画波形1
	int nCntFill = 0;
	VEC_PT ptFillOne;
	VEC2_PT ptFill;
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(m_nHPos) * dXGap);
		}
		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf[m_nHPos] / dYGap * dHfe);
		pDc->MoveTo(pt);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
		{	//填充
			AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
		}
		for (int i = m_nHPos; i < Pile_Info.sDataCnt - Ham_Info.nMoveL_R[0]; ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine;
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe);
			}
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[0];
			pDc->LineTo(pt);
			if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
			{	//填充
				AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
			}
			dXSite += dXGap;
		}

		//画趋势项
// 		rtText.left = nToLeft;
// 		rtText.top = nBaseLine - 30;
// 		rtText.right = nToLeft + 50;
// 		rtText.bottom = nBaseLine;
// 		strText.Format(L"%.f阶拟合多项式", DataBuf[4095]);
// 		pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
// 		pen.CreatePen(PS_SOLID, 1, RGB(255,0,0));
// 		OldPen = pDc->SelectObject(&pen);
// 		int nB = DataBuf[2048];
// 		dXSite = nToLeft + (nB - m_nHPos) * dXGap;
// 		pt.x = (long)dXSite;
// 		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf[2049] / dYGap * dHfe);
// 		pDc->MoveTo(pt);
// 		for (int i = 2049; i < 4096 - nB; ++i)
// 		{
// 			dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe);
// 			pt.x = (long)dXSite;
// 			pt.y = (long)dYSite - Ham_Info.nMoveU_D[0];
// 			pDc->LineTo(pt);
// 			dXSite += dXGap;
// 		}
// 		pDc->SelectObject(OldPen);
// 		pen.DeleteObject();
	}	
	 pDc->SelectObject(OldPen);
	 pen.DeleteObject();

	m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
	dXSite = nToLeft;
	dYSite = 0.0;

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	//画波形2
	if (g_FileType == FILE_DOUBLE_SPEED && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(m_nHPos2) * dXGap);
		}
		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf1[m_nHPos2] / dYGap * dHfe);
		pDc->MoveTo(pt);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
		{	//填充
			AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
		}
		for (int i = m_nHPos2; i < Pile_Info.sDataCnt - (Ham_Info.nMoveL_R[1]); ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine;
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
			}
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[1];
			pDc->LineTo(pt);
			if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
			{	//填充
				AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
			}
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	if (g_bBtnFillWave)
	{	//填充波形
		DrawFillWave(pDc, ptFill);
	}

	pDc->SelectObject(OldFont);
	font.DeleteObject();
	*/
}

double CDrawWave::GetKeDu(double dLen, double dHfe, DT56_PILE_INFO Pile_Info, int nNo)
{
	double dKeDu = dLen * dHfe;
	dKeDu = (dKeDu * Pile_Info.fSensorS[nNo]) / 100.0;
	return dKeDu;
}

//获取字号大小
int CDrawWave::GetWordNum()
{
	int nWordNum = 10;
	nWordNum = g_PrintSetInfo.sWordSize;
	if (nWordNum < g_nWordSizeMin)
	{
		nWordNum = g_PrintSetInfo.sWordSize = 6;
	}
// 	if (g_PrintSetInfo.nLine == 2 )
// 	{
// 		nWordNum = 8;
// 	}
// 	else if (g_PrintSetInfo.nLine == 3)
// 	{
// 		nWordNum = 6;
// 	}
// 
// 	if (g_PrintSetInfo.nRow >= 10)
// 	{
// 		nWordNum = 6;
// 	}
// 	else if (g_PrintSetInfo.nRow >= 8)
// 	{
// 		nWordNum = 8;
// 	}
// 	else if (g_PrintSetInfo.nRow >= 6)
// 	{
// 		nWordNum = 10;
// 	}
// 	else if (g_PrintSetInfo.nRow >= 4)
// 	{
// 		nWordNum = 12;
// 	}
// 
// 	if (g_DrawPicType == Draw_ToolPic)
// 	{
// 		nWordNum += 2;
// 	}

	int nNum = MulDiv(nWordNum, m_nY, 72);
	if (g_DrawPicType == Draw_ToolPic && g_SysSet.nPicType == 3)
	{
		nNum = nWordNum;
	}

	return nNum;
}

//画打印的波形和桩型图
void CDrawWave::DrawPrintWave(CDC *pDc, int nNo, CRect rtPrint, BOOL bDir)
{
	CString strStrings = L"";
//	int nWordNum = GetWordNum();

	DT56_PROJECT_INFO Pro_Info;
	DT56_PILE_INFO Pile_Info;
	DT56_HAM_INFO Ham_Info;
	//获取桩号和锤号
	REPORT_NO RptNo = m_pData->m_vecPrintReport.at(nNo);
	//获取桩信息和锤信息
//	Pro_Info = m_pData->m_vecPro.at(m_pData->m_nSelPileNo);
	Pro_Info = m_pData->m_vecPro.at(RptNo.nPileNo);		//qzg 2020.7.13

	Pro_Info = m_pData->m_vecPro.at(RptNo.nPileNo);
	Pile_Info = m_pData->m_vecPile.at(RptNo.nPileNo);
	if (RptNo.nHamNo == AVG_WAVE_NO)
	{
		Ham_Info = m_pData->m_vecAvgHam.at(RptNo.nPileNo);
	}
	else
	{
		Ham_Info = m_pData->m_vvecHam[RptNo.nPileNo].at(RptNo.nHamNo);
	}
//	CFont	font, *fontOld = NULL;
	CString strVal(L"");
	CSize szFont;
	int nPosX = 0; 
	int nPosY = 0;
	double dBeiShu = 2;
	if (g_DrawPicType == Draw_ToolPic)
	{
		dBeiShu = 1.5;
	}
	if (bDir) //横向
	{
// 		font.CreateFont(nWordNum, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 		fontOld = pDc->SelectObject(&font);
		strVal = L"测试";
		szFont = pDc->GetOutputTextExtent(strVal);
		nPosX = rtPrint.left + szFont.cx / 4;
		nPosY = int(rtPrint.top + (szFont.cy * dBeiShu - szFont.cy) / 2);

		pDc->MoveTo(rtPrint.left, int(rtPrint.top + szFont.cy * dBeiShu));
		pDc->LineTo(rtPrint.right, int(rtPrint.top + szFont.cy * dBeiShu));
	}
	else //纵向
	{
// 		font.CreateFont(nWordNum, 0, 2700, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 		fontOld = pDc->SelectObject(&font);
		strVal = L"测试";
		szFont = pDc->GetOutputTextExtent(strVal);
		nPosX = int(rtPrint.right - (szFont.cy * dBeiShu - szFont.cy )/ 2);
		nPosY = rtPrint.top + szFont.cx / 4;

		pDc->MoveTo(int(rtPrint.right - szFont.cy * dBeiShu), rtPrint.top);
		pDc->LineTo(int(rtPrint.right - szFont.cy * dBeiShu), rtPrint.bottom);
	}
// 	pDc->SelectObject(fontOld);
// 	font.DeleteObject();

	if (1 == g_ReportType.nNo)
	{
		//序号
		strStrings = g_LoadString(L"DW_7");
		strVal.Format(L"%d", nNo + 1);
		strVal = strStrings + strVal;
		//	strVal.Format(L"序号：%d", nNo + 1);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nPileNo)
	{
		//桩号
		strStrings = g_LoadString(L"DW_8");
		strVal = Pile_Info.chPileNo;
		strVal = strStrings + strVal;
		//	strVal = L"桩号：" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nHamNo)
	{
		//锤号
		strStrings = g_LoadString(L"DW_41");
		strVal.Format(L"%d", Ham_Info.sHamNum);
		strVal = strStrings + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}


	if (1 == g_ReportType.nPileLen)
	{
		//桩长
		strStrings = g_LoadString(L"DW_9");
		strVal.Format(L"%.02fm", Ham_Info.fPileLen);
		strVal = strStrings + strVal;
		//	strVal.Format(L"桩长：%.02fm", Ham_Info.fPileLen);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nPileXing)
	{
		//桩型
		strStrings = g_LoadString(L"DW_40");
		strVal = g_strPileStyel[Pile_Info.chPileStyle];
		strVal = strStrings + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nPileLeiXing)
	{
		//桩类型
		strStrings = g_LoadString(L"DW_42");
		strVal = g_strPileType[Pile_Info.chPileType];
		strVal = strStrings + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nPileJing)
	{
		//桩径
		strStrings = g_LoadString(L"DW_10");
		if (IsSquarePile((CString)Pile_Info.chDataType, Pile_Info.chPileStyle))
		{
			strVal.Format(L"%d x %dmm", Pile_Info.sPileDiameter, Pile_Info.sPileDiameterW);
		}
		else
		{
			strVal.Format(L"%dmm", Pile_Info.sPileDiameter);
		}
		
		strVal = strStrings + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nWaveSpeed)
	{
		//波速
		strStrings = g_LoadString(L"DW_11");
		strVal.Format(L"%dm/s", Ham_Info.nWaveSpeed);
		strVal = strStrings + strVal;
		//	strVal.Format(L"波速:%dm/s", Ham_Info.nWaveSpeed);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	if (1 == g_ReportType.nPileType)
	{
		//桩类别
		strStrings = g_LoadString(L"DW_12");
		strVal = g_strPileClass[Pile_Info.chPileClass];
		strVal = strStrings + strVal;
		//	strVal = L"桩类别:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//强度等级
	if (1 == g_ReportType.nQDGrade)
	{
		strVal = g_strTongGrade[Pile_Info.chTongGrade];
		strStrings = g_LoadString(L"DW_13");
		strVal = strStrings + strVal;
//		strVal = L"强度等级:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//检测依据
	if (1 == g_ReportType.nJCYiJu)
	{
		strVal = Pro_Info.chJianCeYiJu;
		strStrings = g_LoadString(L"DW_14");
		strVal = strStrings + strVal;
//		strVal = L"检测依据:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//采样参数 采样间隔
	if (1 == g_ReportType.nCaiYang)
	{
		strStrings = g_LoadString(L"DW_15");
		strVal.Format(L"%d kHz", g_nFrq[Pile_Info.sCaiYangFreq]/1000);
		strVal = strStrings + strVal;
//		strVal.Format(L"采样参数:%.01f", Pile_Info.fCaiYangSpace);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//小波参数
	if (1 == g_ReportType.nWavelet)
	{
		if (g_FileType == FILE_DOUBLE_SPEED)
		{
			strStrings = g_LoadString(L"DW_16");
			strVal.Format(L"%.0f", Ham_Info.fWaveletConver[0]);
			strVal = strStrings + strVal;
//			strVal.Format(L"小波参数1:%.0f", Ham_Info.fWaveletConver[0]);
			DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);

			strStrings = g_LoadString(L"DW_17");
			strVal.Format(L"%.0f", Ham_Info.fWaveletConver[1]);
			strVal = strStrings + strVal;
//			strVal.Format(L"小波参数2:%.0f", Ham_Info.fWaveletConver[1]);
			DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
		}
		else
		{
			strStrings = g_LoadString(L"DW_18");
			strVal.Format(L"%.0f", Ham_Info.fWaveletConver[0]);
			strVal = strStrings + strVal;
//			strVal.Format(L"小波参数:%.0f", Ham_Info.fWaveletConver[0]);
			DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
		}
		
	}
	//指数放大
	if (1 == g_ReportType.nExp)
	{
		strStrings = g_LoadString(L"DW_19");
		strVal.Format(L"%d", Ham_Info.sExpEnlargeNum);
		strVal = strStrings + strVal;
//		strVal.Format(L"指数放大:%d", Ham_Info.sExpEnlargeNum);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//低通
	if (1 == g_ReportType.nLP)
	{
		strStrings = g_LoadString(L"DW_20");
		strVal.Format(L"%d", Ham_Info.nFilterLowFrq);
		strVal = strStrings + strVal;
//		strVal.Format(L"低通:%d", Ham_Info.nFilterLowFrq);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//高通
	if (1 == g_ReportType.nHP)
	{
		strStrings = g_LoadString(L"DW_21");
		strVal.Format(L"%d", Ham_Info.nFilterHightFrq);
		strVal = strStrings + strVal;
//		strVal.Format(L"高通:%d", Ham_Info.nFilterHightFrq);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//H1
	if (1 == g_ReportType.nH1 && g_FileType == FILE_DOUBLE_SPEED)
	{
		strVal.Format(L"H1:%d", Pile_Info.fSensorH[0]);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//H2
	if (1 == g_ReportType.nH2 && g_FileType == FILE_DOUBLE_SPEED)
	{
		strVal.Format(L"H2:%d", Pile_Info.fSensorH[1]);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//距离差
	if (1 == g_ReportType.nJuLiCha && g_FileType == FILE_DOUBLE_SPEED)
	{
		strStrings = g_LoadString(L"DW_22");
		strVal.Format(L"%d", Pile_Info.fSensorH[0] - Pile_Info.fSensorH[1]);
		strVal = strStrings + strVal;
//		strVal.Format(L"距离差:%d", Pile_Info.fSensorH[0] - Pile_Info.fSensorH[1]);
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//长径比
	if (1 == g_ReportType.nChangJingBi)
	{
		strStrings = g_LoadString(L"DW_23");
		strVal.Format(L"%.01f", float(Ham_Info.fPileLen * 1000 / Pile_Info.sPileDiameter));
		strVal = strStrings + strVal;
//		strVal.Format(L"长径比:%.01f", float(Ham_Info.fPileLen * 100 / Pile_Info.sPileDiameter));
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//仪器型号
	if (1 == g_ReportType.nYiQiTyle)
	{
		strVal = Pro_Info.chYiQiStyle;
		strStrings = g_LoadString(L"DW_24");
		strVal = strStrings + strVal;
//		strVal = L"仪器型号:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	//仪器编号
	if (1 == g_ReportType.nYiQiNO)
	{
		strVal = Pro_Info.chYiQiNum;
		strStrings = g_LoadString(L"DW_39");
		strVal = strStrings + strVal;
		//		strVal = L"仪器型号:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	//检测日期
	if (1 == g_ReportType.nJCDate)
	{
		strVal = Pro_Info.chJianCeDate;
		if (0 == g_ReportType.nTime)
		{
			strVal = strVal.Left(10);
		}
		else
		{
			if (!g_SysSet.chShowSecond)
			{
				strVal = strVal.Left(16);
			}
		}
		strStrings = g_LoadString(L"DW_25");
		strVal = strStrings + strVal;
//		strVal = L"检测日期:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}
	//其他
	if (1 == g_ReportType.nOther)
	{
		strVal = g_ReportType.strOther;
		strStrings = g_LoadString(L"DW_26");
		strVal = strStrings + strVal;
//		strVal = L"其他:" + strVal;
		DrawPrintReportType(pDc, strVal, nPosX, nPosY, rtPrint, bDir);
	}

	//重新计量剩余区域大小
	if (bDir)
	{
		rtPrint.top += szFont.cy * 2;
	}
	else
	{
		rtPrint.right -= szFont.cy * 2;
	}
	//完整性评价
	if (1 == g_ReportType.nDescribe)
	{
		if (bDir) //横向
		{
// 			font.CreateFont(nWordNum, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 			fontOld = pDc->SelectObject(&font);
			strVal = L"测试";
			szFont = pDc->GetOutputTextExtent(strVal);

			nPosX = rtPrint.left + szFont.cx / 4;
			nPosY = int(rtPrint.bottom - (szFont.cy * dBeiShu - szFont.cy) / 2 - szFont.cy);

			strVal = Ham_Info.chDescribe;
			strStrings = g_LoadString(L"DW_27");
			strVal = strStrings + strVal;
//			strVal = L"完整性评价:" + strVal;
			pDc->TextOutW(nPosX, nPosY, strVal);

			pDc->MoveTo(rtPrint.left, int(rtPrint.bottom - szFont.cy * dBeiShu));
			pDc->LineTo(rtPrint.right, int(rtPrint.bottom - szFont.cy * dBeiShu));

			rtPrint.bottom -= long(szFont.cy * dBeiShu);
		}
		else //纵向
		{
// 			font.CreateFont(nWordNum, 0, 2700, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 			fontOld = pDc->SelectObject(&font);
			strVal = L"测试";
			szFont = pDc->GetOutputTextExtent(strVal);
			nPosX = rtPrint.left + int((szFont.cy * dBeiShu - szFont.cy) / 2) + szFont.cy;
			nPosY = rtPrint.top + szFont.cx / 4;

			strVal = Ham_Info.chDescribe;
			strStrings = g_LoadString(L"DW_27");
			strVal = strStrings + strVal;
//			strVal = L"完整性评价:" + strVal;
			pDc->TextOutW(nPosX, nPosY, strVal);

			pDc->MoveTo(int(rtPrint.left + szFont.cy * dBeiShu), rtPrint.top);
			pDc->LineTo(int(rtPrint.left + szFont.cy * dBeiShu), rtPrint.bottom);

			rtPrint.left += int(szFont.cy * dBeiShu);
		}
// 		pDc->SelectObject(fontOld);
// 		font.DeleteObject();
	}

	//画波形和桩
	DrawPrintWaveInfo(pDc, Pile_Info, Ham_Info, RptNo.nPileNo, RptNo.nHamNo, rtPrint, bDir);
//	if (1 == g_ReportType.nPileLen)
	{
		DrawPrintPileInfo(pDc, Pile_Info, Ham_Info, RptNo.nPileNo, RptNo.nHamNo, rtPrint, bDir);
	}
}

//画打印预览的波形和桩
void CDrawWave::DrawPrintWaveInfo(CDC *pDc, DT56_PILE_INFO Pile_Info, DT56_HAM_INFO Ham_Info, int nPileNo, int nHamNo, CRect rtPrint, BOOL bDir)
{
//	int nWordNum = GetWordNum();
	WSDATA DataBuf = { 0 };
	WSDATA DataBuf1 = { 0 };
	int	nDescribe = 0;		//判断完整性评价

// 	CFont font, *OldFont = NULL;
// 	if (bDir)
// 	{
// 		font.CreateFont(nWordNum, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 	}
// 	else
// 	{
// 		font.CreateFont(nWordNum, 0, 2700, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 	}
// 	OldFont = pDc->SelectObject(&font);

	CString strNum(L"0");
	CSize szNum = 0;
	szNum = pDc->GetOutputTextExtent(strNum);

	int nHPos = 0;
	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = rtPrint.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtPrint.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtPrint.Width() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = 0;
	if (1 == g_ReportType.nDescribe)		//完整性评价
	{
		nDescribe = 1;
	}
	nV_Hig = rtPrint.Height() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
	int nPileH = szNum.cy;					//桩的高度（宽度）
	if (g_DrawPicType == Draw_ToolPic)
	{
		nPileH = nToTop*2;
	}
	//nToTop一个为顶部距离，一个为底部完整性评价距离
	int nWaveV_Hig = rtPrint.Height() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

	int nrtPrintLeft = rtPrint.left;  
	int nrtPrintTop = rtPrint.top;
	//纵向
	if (!bDir)
	{
		nToLeft = rtPrint.Height() / 25;	//开始画位置距离左侧边框距离 
		nToTop = rtPrint.Width() / 25;		//距离底部位置 也是距离顶部位置 
		nH_Wid = rtPrint.Height() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
		//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
		nV_Hig = rtPrint.Width() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
		nPileH = szNum.cy;					//桩的高度（宽度）
		nWaveV_Hig = rtPrint.Width() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
		nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

		nrtPrintLeft = rtPrint.top;
		nrtPrintTop = rtPrint.right;
	}

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);

	//Y轴两点间距
	double dYGap = 1.0;
	if (nBaseLine + Ham_Info.nMove_YZoom < 5 * nToTop)
	{
		Ham_Info.nMove_YZoom = 5 * nToTop - nBaseLine;
	}
	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	if (dMax >(nWaveV_Hig) * 1.0 / 2)
	{
		dYGap = dMax / ((nWaveV_Hig)* 1.0 / 2);
	}

	//X轴两点间距
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
// 	if (Ham_Info.nMove_XZoom < 0)
// 	{
// 		Ham_Info.nMove_XZoom = 0;
// 	}
// 	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom) * 1.0);
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);

	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
	nHPos = GetBeginPos(dXGap, nH_Wid, Ham_Info);

//	double dLen = GetYLen(dMax, Pile_Info);;
//	int nPileBottom = GetPileBottomPoints(Ham_Info, Pile_Info);		//桩底位置
// 	int nHPos = GetBeginPos(dXGap, rtPrint, Ham_Info);
// 	int nPileTop = Ham_Info.sPileTopPos;			//桩顶位置


	double dHfe = pow(2, (Ham_Info.sVZoom - 49 + Ham_Info.nMove_YZoom) / 15.0);

//	double dKeDu = GetKeDu(dLen, dHfe, Pile_Info);
// 	double dKeDu = dLen * dHfe;
// 	dKeDu = (dKeDu * Pile_Info.fSensorS[0]) / 100.0;
// 	double dKeDu1 = 0;
// 	//双波形就要判断哪个波形的最大了
// 	if (g_FileType == FILE_DOUBLE_SPEED)
// 	{
// 		dKeDu1 = (dLen * Pile_Info.fSensorS[0]) / 100.0;
// 		dKeDu = dKeDu > dKeDu1 ? dKeDu : dKeDu1;
// 	}

	CPoint pt;

	//绘制曲线
// 	double dXSite = rtPrint.left + nToLeft;
// 	double dYSite = (double)rtPrint.top;
	double dXSite = nrtPrintLeft + nToLeft;
	double dYSite = (double)nrtPrintTop;
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		GetDataBuf(DataBuf1, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 1);
	}

// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	//	m_nHPos = nHPos;
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	//画波形1
	int nCntFill = 0;
	VEC_PT ptFillOne;
	VEC2_PT ptFill;
//	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));				//qzg 2020.7.13

	OldPen = pDc->SelectObject(&pen);
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		if (bDir)	//横向
		{
			pt.x = (long)dXSite;
			if (m_nHPos < 0)
			{
				pt.x = (long)(dXSite + abs(m_nHPos) * dXGap);
				pt.y = rtPrint.top + (long)nBaseLine;
			}
			else
			{
				pt.y = rtPrint.top + (long)nBaseLine - (int)(g_nWaveResever * DataBuf[m_nHPos] / dYGap * dHfe);
			}
			
		}
		else
		{
			pt.y = (long)dXSite;
			if (m_nHPos < 0)
			{
				pt.y = (long)(dXSite + abs(m_nHPos) * dXGap);
				pt.x = rtPrint.right - nBaseLine;
			}
			else
			{
				pt.x = rtPrint.right - ((long)nBaseLine - (int)(g_nWaveResever * DataBuf[m_nHPos] / dYGap * dHfe));
			}
			
		}
		
		pDc->MoveTo(pt);

		for (int i = m_nHPos; i < Pile_Info.sDataCnt - Ham_Info.nMoveL_R[0]; ++i)
		{
			if (dXSite >= nrtPrintLeft + nToLeft + nH_Wid)
			{
				break;
			}

			if (bDir)
			{
				if (i < 0)
				{
					dYSite = rtPrint.top + nBaseLine;
					dXSite += dXGap;
					continue;
				}
				else
				{
					dYSite = rtPrint.top + nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe);
				}
				
				pt.x = (long)dXSite;
				pt.y = (long)dYSite - Ham_Info.nMoveU_D[0];
			}
			else
			{
				if (i < 0)
				{
					dYSite = rtPrint.right - (nBaseLine);
					dXSite += dXGap;
					continue;
				}
				else
				{
					dYSite = rtPrint.right - (nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe));
				}
				
				pt.y = (long)dXSite;
				pt.x = (long)dYSite - Ham_Info.nMoveU_D[0];
			}
			
			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
	dXSite = nrtPrintLeft + nToLeft;
	dYSite = (double)nrtPrintTop;
	//画波形2
//	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));				//qzg 2020.7.13

	OldPen = pDc->SelectObject(&pen);

	if (g_FileType == FILE_DOUBLE_SPEED && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		if (bDir)
		{
			pt.x = (long)dXSite;
			if (m_nHPos < 0)
			{
				pt.x = (long)(dXSite + abs(m_nHPos) * dXGap);
			}
			pt.y = rtPrint.top + (long)nBaseLine - (int)(g_nWaveResever * DataBuf1[m_nHPos2] / dYGap * dHfe);
		}
		else
		{
			pt.y = (long)dXSite;
			if (m_nHPos < 0)
			{
				pt.y = (long)(dXSite + abs(m_nHPos) * dXGap);
			}
			pt.x = rtPrint.right - ((long)nBaseLine - (int)(g_nWaveResever * DataBuf1[m_nHPos2] / dYGap * dHfe));
		}
	
		pDc->MoveTo(pt);
		for (int i = m_nHPos2; i < Pile_Info.sDataCnt - (Ham_Info.nMoveL_R[1]); ++i)
		{
			if (dXSite >= nrtPrintLeft + nToLeft + nH_Wid)
			{
				break;
			}
			if (bDir)
			{
				if (i < 0)
				{
					dYSite = rtPrint.top + nBaseLine;
				}
				else
				{
					dYSite = rtPrint.top + nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
				}
				
				pt.x = (long)dXSite;
				pt.y = (long)dYSite - Ham_Info.nMoveU_D[1];
			}
			else
			{
				
				if (i < 0)
				{
					dYSite = rtPrint.right - (nBaseLine);
				}
				else
				{
					dYSite = rtPrint.right - (nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe));
				}
				pt.y = (long)dXSite;
				pt.x = (long)dYSite + Ham_Info.nMoveU_D[1];
			}
			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
// 	pDc->SelectObject(OldFont);
// 	font.DeleteObject();
}

//画波形 图片
void CDrawWave::DrawPrintWaveInfoPic(CDC *pDc, DT56_PILE_INFO Pile_Info, DT56_HAM_INFO Ham_Info, int nPileNo, int nHamNo, CRect rtPrint)
{
	int	nDescribe = 0;		//判断完整性评价

	WSDATA DataBuf = { 0 };
	WSDATA DataBuf1 = { 0 };

	CPen pen, *OldPen = NULL;

	CString strNum(L"0");
	CSize szNum = 0;
	szNum = pDc->GetTextExtent(strNum);

	if (1 == g_ReportType.nDescribe)		//完整性评价
	{
		nDescribe = 1;
	}

	int nHPos = 0;
	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率

	int nToLeft = rtPrint.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtPrint.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtPrint.Width() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = rtPrint.Height() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
	int nPileH = nToTop * 2;					//桩的高度（宽度）
	int nWaveV_Hig = rtPrint.Height() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

	int nrtPrintLeft = rtPrint.left;
	int nrtPrintTop = rtPrint.top;

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);

	//Y轴两点间距
	double dYGap = 1.0;
	if (nBaseLine + Ham_Info.nMove_YZoom < 5 * nToTop)
	{
		Ham_Info.nMove_YZoom = 5 * nToTop - nBaseLine;
	}
	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	if (dMax >(nWaveV_Hig) * 1.0 / 2)
	{
		dYGap = dMax / ((nWaveV_Hig)* 1.0 / 2);
	}

	//X轴两点间距
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);

	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);

//	double dLen = GetYLen(dMax, Pile_Info);
// 	if (g_WaveShowMode == WAVE_SHOW_V)		//速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8) / (32768 * 2 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * 3;
// 	}
// 	else			//加速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 2 * 100) * 3;
// 	}

// 	int nSite = (int)(dMax / dYGap);  //像素点数
// 	if (0 == nSite)
// 	{
// 		nSite = int(0.3617 * nWaveV_Hig);
// 	}
	double dHfe = pow(2, (Ham_Info.sVZoom - 49 + Ham_Info.nMove_YZoom) / 15.0);

//	double dKeDu = GetKeDu(dLen, dHfe, Pile_Info);
// 	double dKeDu = dLen * dHfe;
// 	dKeDu = (dKeDu * Pile_Info.fSensorS[0]) / 100.0;
// 	double dKeDu1 = 0;
// 	//双波形就要判断哪个波形的最大了
// 	if (g_FileType == FILE_DOUBLE_SPEED)
// 	{
// 		dKeDu1 = (dLen * Pile_Info.fSensorS[0]) / 100.0;
// 		dKeDu = dKeDu > dKeDu1 ? dKeDu : dKeDu1;
// 	}

	CPoint pt;

	//绘制曲线
	// 	double dXSite = rtPrint.left + nToLeft;
	// 	double dYSite = (double)rtPrint.top;
	double dXSite = nrtPrintLeft + nToLeft;
	double dYSite = (double)nrtPrintTop;
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);
	if (g_FileType == FILE_DOUBLE_SPEED)
	{
		GetDataBuf(DataBuf1, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 1);
	}

// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	//	m_nHPos = nHPos;
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	//画波形1
//	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));				//qzg 2020.7.13

	OldPen = pDc->SelectObject(&pen);
	int nCntFill = 0;
	VEC_PT ptFillOne;
	VEC2_PT ptFill;
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap);
		}
		pt.y = rtPrint.top + (long)nBaseLine - (int)(g_nWaveResever * DataBuf[m_nHPos] / dYGap * dHfe);

		pDc->MoveTo(pt);
		for (int i = m_nHPos; i < Pile_Info.sDataCnt - Ham_Info.nMoveL_R[0]; ++i)
		{
			if (dXSite >= nrtPrintLeft + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = rtPrint.top + nBaseLine;
			}
			else
			{
				dYSite = rtPrint.top + nBaseLine - (int)(g_nWaveResever * DataBuf[i] / dYGap * dHfe);
			}
			
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[0];

			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
	dXSite = nrtPrintLeft + nToLeft;
	dYSite = (double)nrtPrintTop;
	//画波形2
//	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));				//qzg 2020.7.13
	OldPen = pDc->SelectObject(&pen);
	if (g_FileType == FILE_DOUBLE_SPEED && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap);
		}
		pt.y = rtPrint.top + (long)nBaseLine - (int)(g_nWaveResever * DataBuf1[m_nHPos2] / dYGap * dHfe);

		pDc->MoveTo(pt);
		for (int i = m_nHPos2; i < Pile_Info.sDataCnt - (Ham_Info.nMoveL_R[1]); ++i)
		{
			if (dXSite >= rtPrint.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = rtPrint.top + nBaseLine;
			}
			else
			{
				dYSite = rtPrint.top + nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
			}
			
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[1];
			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawPrintPileInfo(CDC *pDc, DT56_PILE_INFO Pile_Info, DT56_HAM_INFO Ham_Info, int nPileNo, int nHamNo, CRect rtPrint, BOOL bDir)
{
	int	nDescribe = 0;		//判断完整性评价
//	int nWordNum = GetWordNum();
	WSDATA DataBuf = { 0 };
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);
//	CFont font, *OldFont = NULL;
// 	if (bDir)
// 	{
// 		font.CreateFont(nWordNum, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 	}
// 	else
// 	{
// 		font.CreateFont(nWordNum, 0, 2700, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 	}
//	OldFont = pDc->SelectObject(&font);

	CString strNum(L"5");
	CSize szNum = 0;
	szNum = pDc->GetOutputTextExtent(strNum);

	if (1 == g_ReportType.nDescribe)		//完整性评价
	{
		nDescribe = 1;
	}

//	int nHPos = 0; //一个水平值

	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = rtPrint.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtPrint.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtPrint.Width() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = rtPrint.Height() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
	int nPileH = szNum.cy;					//桩的高度（宽度）
	if (g_DrawPicType == Draw_ToolPic)
	{
		nPileH = nToTop * 2;
	}

	//桩高、桩底部到完整性评价上边高度、完整性评价高度
	int nWaveV_Hig = rtPrint.Height() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

	int nrtPrintLeft = rtPrint.left;
	int nrtPrintTop = rtPrint.top;

	//纵向
	if (!bDir)
	{
		nToLeft = rtPrint.Height() / 25;	//开始画位置距离左侧边框距离 
		nToTop = rtPrint.Width() / 25;		//距离底部位置 也是距离顶部位置 
		nH_Wid = rtPrint.Height() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
		//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
		nV_Hig = rtPrint.Width() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
		nPileH = szNum.cy;					//桩的高度（宽度）
		nWaveV_Hig = rtPrint.Width() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
		nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

		nrtPrintLeft = rtPrint.top;
		nrtPrintTop = rtPrint.right;
	}

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);
	//Y轴两点间距
	double dYGap = 1.0;
	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	//X轴两点间距
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
//	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom/* + Ham_Info.nMove_XZoom*/) * 1.0);

	//int nPileBottom = GetPileBottomPoints(Ham_Info, Pile_Info);		//桩底位置
	int nPileBottom = m_pData->GetPileBottomPoints(Ham_Info, Pile_Info);
	int nHPos = GetBeginPos(dXGap, nH_Wid, Ham_Info);
	int nPileTop = Ham_Info.sPileTopPos;			//桩顶位置

	//桩底 位置计算
//	nPileBottom = (int)(nPileTop + (2.0 * Ham_Info.fPileLen * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
	//将桩顶桩底位置保存到成员变量中
//	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
	//	nHPos = 0;
// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	int nDataCnts = Pile_Info.sDataCnt;  //采样点数
	//对桩顶和桩底位置进行判断
// 	if (nPileTop >= nDataCnts)
// 	{
// 		nPileTop = nDataCnts - 2;
// 		nPileBottom = nDataCnts - 1;
// 	}
// 	else if (nPileBottom >= nDataCnts)
// 	{
// 		nPileBottom = nDataCnts - 1;
// 	}
// 	else{}

	//字体大小
	CSize szFont = pDc->GetOutputTextExtent(L"轻微");
	//背景白色 透明
	// 	pDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	pDc->SetBkMode(TRANSPARENT);

	CRect rtPile; //获取桩区域
	if (bDir) //横向
	{
		rtPile.left = rtPrint.left + int(nToLeft + (nPileTop - nHPos) * dXGap);
		rtPile.top = rtPrint.bottom - szNum.cy * 2 - nPileH - nToTop * nDescribe;
		rtPile.right = rtPrint.left + int(nToLeft + (nPileBottom - nHPos) * dXGap);
		rtPile.bottom = rtPrint.bottom - szNum.cy * 2 - nToTop * nDescribe;
		if (rtPile.right > rtPrint.left + nH_Wid + nToLeft)
		{
			rtPile.right = rtPrint.left + nH_Wid + nToLeft;
		}
	}
	else//纵向
	{
		rtPile.top = rtPrint.top + int(nToLeft + (nPileTop - nHPos) * dXGap) - nToTop * nDescribe;
		rtPile.left = rtPrint.left + szNum.cy * 2 + nPileH;
		rtPile.bottom = rtPrint.top + int(nToLeft + (nPileBottom - nHPos) * dXGap) - nToTop * nDescribe;
		rtPile.right = rtPrint.left + szNum.cy * 2;
		if (rtPile.bottom > rtPrint.top + nH_Wid + nToLeft)
		{
			rtPile.bottom = rtPrint.top + nH_Wid + nToLeft;
		}
	}
	
	if (1 == g_ReportType.nPileShow)
	{
		//画桩
		pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	}


	CRect rtPileDefect = rtPile;
	CRect rtPi = rtPile;
	//桩底类型
	int nPileBtmLong = 65; //桩底类型长度
	int nPileBtmW = 50;
	if (g_DrawPicType == Draw_ToolPic)
	{
		nPileBtmLong = 18;
		nPileBtmW = 14;
	}
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		if (bDir)
		{
			rtPi.left = rtPile.right - nPileBtmLong;
		}
		else
		{
			rtPi.top = rtPile.bottom - nPileBtmLong;
		}
		
		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);

		CPoint ptP[3];
		if (bDir)
		{
			ptP[0] = CPoint(rtPi.left, rtPi.top);
			ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
			ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		}
		else
		{
			ptP[0] = CPoint(rtPi.left, rtPi.top);
			ptP[1] = CPoint(rtPile.left + rtPile.Width() / 2, rtPile.bottom);
			ptP[2] = CPoint(rtPi.right, rtPi.top);
		}		
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{
		if (bDir)
		{
			rtPi.left = rtPile.right - nPileBtmW;
			rtPi.top = rtPile.top - nPileBtmW / 2;
			rtPi.bottom = rtPile.bottom + nPileBtmW / 2;
		}
		else
		{
			rtPi.left = rtPile.left - 25;
			rtPi.top = rtPile.bottom - 50;
			rtPi.right = rtPile.right + 25;
		}
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
	CPoint pt = 0;
	double dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	if (g_WaveShowMode == WAVE_SHOW_V)
	{
		//PS_DOT点线
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);

		if (1 == g_ReportType.nPileShow)
		{
			//画桩头
			if (bDir)
			{
				pt.x = rtPile.left;
				pt.y = rtPile.top;
				pDc->MoveTo(pt);
				pt.y = rtPrint.top + nBaseLine - int(g_nWaveResever * DataBuf[nPileTop] / dYGap * dHfe);
				pDc->LineTo(pt);
			}
			else
			{
				pt.x = rtPile.right;
				pt.y = rtPile.top;
				pDc->MoveTo(pt);
				pt.x = rtPrint.right - (nBaseLine - int(g_nWaveResever * DataBuf[nPileTop] / dYGap * dHfe));
				pDc->LineTo(pt);
			}

			//画桩尾
			if (bDir)
			{
				pt.x = rtPile.right - 1;
				pt.y = rtPile.top;
				pDc->MoveTo(pt);
				pt.y = rtPrint.top + nBaseLine - int(g_nWaveResever * DataBuf[nPileBottom] / dYGap * dHfe);
				pDc->LineTo(pt);
			}
			else
			{
				pt.x = rtPile.right - 1;
				pt.y = rtPile.bottom;
				pDc->MoveTo(pt);
				pt.x = rtPrint.right - (nBaseLine - int(g_nWaveResever * DataBuf[nPileBottom] / dYGap * dHfe));
				pDc->LineTo(pt);

			}
		}

		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}

	CString strStrings(L"");
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strStrings = g_LoadString(L"DW_28");
		pDc->DrawText(strStrings, rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
//		pDc->DrawText(L"加速度曲线", rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
	}
	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画竖坐标线
// 	if (bDir)
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			pt.x = rtPrint.left + nToLeft;
// 			pt.y = rtPrint.bottom;
// 			pDc->MoveTo(pt);
// 			pt.y = rtPrint.top + 75;
// 			pDc->LineTo(pt);
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			pt.x = rtPrint.left + nToLeft;
// 			pt.y = rtPrint.bottom;
// 			pDc->MoveTo(pt);
// 			pt.y = rtPrint.top + 20;
// 			pDc->LineTo(pt);
// 		}
// 	}
// 	else
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			pt.x = rtPrint.left;
// 			pt.y = rtPrint.top + nToLeft;
// 			pDc->MoveTo(pt);
// 			pt.x = rtPrint.right - 75;
// 			pDc->LineTo(pt);
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			pt.x = rtPrint.left;
// 			pt.y = rtPrint.top + nToLeft;
// 			pDc->MoveTo(pt);
// 			pt.x = rtPrint.right - 20;
// 			pDc->LineTo(pt);
// 		}
// 	}
	
	//画箭头
 	CPoint ptArr[3];
// 	if (bDir)
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			ptArr[0] = CPoint(pt.x, pt.y - 50);
// 			ptArr[1] = CPoint(pt.x - 15, pt.y);
// 			ptArr[2] = CPoint(pt.x + 15, pt.y);
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			ptArr[0] = CPoint(pt.x, pt.y - 10);
// 			ptArr[1] = CPoint(pt.x - 3, pt.y);
// 			ptArr[2] = CPoint(pt.x + 3, pt.y);
// 		}
// 		
// 	}
// 	else
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			ptArr[0] = CPoint(pt.x + 50, pt.y);
// 			ptArr[1] = CPoint(pt.x, pt.y - 15);
// 			ptArr[2] = CPoint(pt.x, pt.y + 15);
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			ptArr[0] = CPoint(pt.x + 10, pt.y);
// 			ptArr[1] = CPoint(pt.x, pt.y - 3);
// 			ptArr[2] = CPoint(pt.x, pt.y + 3);
// 		}
// 		
// 	}
// 	pDc->Polygon(ptArr, 3);

	//横坐标
	if (bDir)
	{
		pt.x = rtPrint.left + nToLeft;
		pt.y = rtPrint.bottom - szNum.cy * 3 / 2;
		pDc->MoveTo(pt);
		pt.x = rtPrint.left + nToLeft + nH_Wid;
		pDc->LineTo(pt);
	}
	else
	{
		pt.y = rtPrint.top + nToLeft;
		pt.x = rtPrint.left + szNum.cy * 3 / 2;
		pDc->MoveTo(pt);
		pt.y = rtPrint.top + nToLeft + nH_Wid;
		pDc->LineTo(pt);
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	if (bDir)
	{
		pt.x = rtPrint.left + nToLeft;
		pt.y = rtPrint.top + nBaseLine;
		pDc->MoveTo(pt);
		pt.x = rtPrint.left + nToLeft + nH_Wid;
		pDc->LineTo(pt);
	}
	else
	{
		pt.y = rtPrint.top + nToLeft;
		pt.x = rtPrint.right - nBaseLine;
		pDc->MoveTo(pt);
		pt.y = rtPrint.top + nToLeft + nH_Wid;
		pDc->LineTo(pt);
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
// 	if (bDir)
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			ptArr[0] = pt;
// 			ptArr[1] = CPoint(pt.x - 50, pt.y - 15);
// 			ptArr[2] = CPoint(pt.x - 50, pt.y + 15);
// 
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			ptArr[0] = pt;
// 			ptArr[1] = CPoint(pt.x - 10, pt.y - 3);
// 			ptArr[2] = CPoint(pt.x - 10, pt.y + 3);
// 		}
// 	}
// 	else
// 	{
// 		if (g_DrawPicType == Draw_Printveiw)
// 		{
// 			ptArr[0] = pt;
// 			ptArr[1] = CPoint(pt.x - 15, pt.y - 50);
// 			ptArr[2] = CPoint(pt.x + 15, pt.y - 50);
// 
// 		}
// 		else if (g_DrawPicType == Draw_ToolPic)
// 		{
// 			ptArr[0] = pt;
// 			ptArr[1] = CPoint(pt.x - 3, pt.y - 10);
// 			ptArr[2] = CPoint(pt.x + 3, pt.y - 10);
// 		}
// 	}
// 	pDc->Polygon(ptArr, 3);

	//画刻度
	//一平所占的长度（米）
// 	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
// 	dLen = (Pile_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(Ham_Info.fPileLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;
	int nPosX = 0;
	int nPosY = 0;
	CSize szText;
	for (int i = 0; i < nDataCnts; ++i)
	{
		dMarkLen = double(i * dGap);
		nSite = int(dMarkLen * 10);
		nStepStart = int((i + nPileTop - nHPos) * dXGap) + nrtPrintLeft + nToLeft;
		//如果出了坐标轴就不画了
		if (nStepStart > nrtPrintLeft + nToLeft + nH_Wid)
		{
			break;
		}
		if (nSite == nSiteBack)
		{
			continue;
		}
		nSiteBack = nSite;
		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
		{
			if (bDir)
			{
				pDc->MoveTo(nStepStart, rtPrint.bottom - szNum.cy * 3 / 2);
				pDc->LineTo(nStepStart, rtPrint.bottom - szNum.cy);
				rtNum.SetRect(nStepStart - 10, rtPrint.bottom - szNum.cy, nStepStart + 10, rtPrint.bottom);
				if (g_DrawPicType == Draw_ToolPic)
				{
					rtNum.SetRect(nStepStart - 10, rtPrint.bottom - szNum.cy - 2, nStepStart + 10, rtPrint.bottom);
				}
			}
			else
			{
				pDc->MoveTo(rtPrint.left + szNum.cy * 3 / 2, nStepStart);
				pDc->LineTo(rtPrint.left + szNum.cy, nStepStart);
		//		rtNum.SetRect(rtPrint.left + szNum.cy / 2, nStepStart - 20, rtPrint.left + szNum.cy * 2, nStepStart + 20);
				nPosX = rtPrint.left + szNum.cy ;
				if (g_DrawPicType == Draw_ToolPic)
				{
					nPosX = rtPrint.left + szNum.cy + 2;
				}
			}	
			
			if (g_AbscissaMode == ABSCISSA_TIME)
			{
				if (0 == nSite)
				{
					strText = L"0.0";
				}
				else
				{
					strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
				}
			}
			else //横坐标长度
			{
				strText.Format(L"%d", (int)dMarkLen);
			}
			
			if (bDir)
			{
				pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
			}
			else
			{
				szText = pDc->GetTextExtent(strText);
				nPosY = nStepStart - szText.cx / 2;
				pDc->TextOutW(nPosX, nPosY, strText);
			}
			
		}
		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
		{
			if (bDir)
			{
				pDc->MoveTo(nStepStart, rtPrint.bottom - szNum.cy * 3 / 2);
				pDc->LineTo(nStepStart, rtPrint.bottom - szNum.cy - szNum.cy / 4);
			}
			else
			{
				pDc->MoveTo(rtPrint.left + szNum.cy * 3 / 2, nStepStart);
				pDc->LineTo(rtPrint.left + szNum.cy + szNum.cy / 4, nStepStart);
			}	
		}

	}
	//横坐标单位 时间或者长度
	if (g_AbscissaMode == ABSCISSA_LEN)
	{
		strText = L"m";
	}
	else
	{
		strText = L"ms";
	}
	
	if (bDir)
	{
		pDc->TextOutW(rtPrint.left + nToLeft + nH_Wid + szNum.cx, rtPrint.bottom - szNum.cy * 3 / 2, strText);
	}
	else
	{
		pDc->TextOutW(rtPrint.left + szNum.cy * 3 / 2, rtPrint.top + nToLeft + nH_Wid + szNum.cx, strText);
	}
	
	//纵坐标单位 速度或者加速度
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strText = L"m/s²";
	}
	else
	{
		strText = L"cm/s";
	}
	if (bDir)
	{
		pt = CPoint(rtPrint.left + nToLeft + 20, rtPrint.top + nToTop);
	}
	else
	{
		pt = CPoint(rtPrint.right - nToTop, rtPrint.top + nToLeft + 20);
	}
//	pDc->TextOutW(pt.x, pt.y, strText);
	szText = pDc->GetOutputTextExtent(L"m/s²");

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	if (0 == g_ReportType.nDefectPos)
	{
// 		pDc->SelectObject(OldFont);
// 		font.DeleteObject();
		return;
	}
	//画缺陷
	int nDefLong = 20;
	if (g_DrawPicType == Draw_ToolPic)
	{
		nDefLong = 5;
	}
	//波形1缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint ptDefect;
	CString strDefect;
	CRect rtDef = rtPileDefect;
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
		{	//判断缺陷是否出界
			if (Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[0].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[0].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
		
			if (bDir)
			{
				ptDefect.x = rtPrint.left + int(nToLeft + (dPos - nHPos) * dXGap);
			//	ptDefect.y = rtPrint.bottom - 7 * nToTop;
				ptDefect.y = long(rtPrint.bottom - 2.2 * szNum.cy - nPileH);
				pDc->MoveTo(ptDefect);
				ptDefect.y = rtPrint.top + nToTop;
				pDc->LineTo(ptDefect);

				strDefect = L"";
				if (g_sysInfo.nCheckShow)
				{
					//桩长
					strDefect.Format(L"%.02fm", Ham_Info.WA_Info[0].fDefectPos[i]);
					if (g_SysSet.nDefectDot == 0)
					{
						strDefect.Format(L"%.01fm", Ham_Info.WA_Info[0].fDefectPos[i]);
					}
				}

				strText = strDefect;
				strText += m_pData->GetDefectLevel(Ham_Info, i);
				strText += m_pData->GetDefectType(Ham_Info, i);
// 				strText += g_strDefectLevel[Ham_Info.WA_Info[0].chDefectLevel[i]];
// 				strText += g_strDefectType[Ham_Info.WA_Info[0].chDefectType[i]];
				//			strDefect += strText;
				szText = pDc->GetOutputTextExtent(strText);
				pDc->SetTextColor(g_SysSet.Cuver1clr);
				int nToTopHight = 0;	 //字体距离顶部的倍数
				if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(ptDefect.x - szText.cx + 5, rtPrint.top + nToTop + nToTopHight * szText.cy, strText);
				}
				else
				{
					pDc->TextOutW(ptDefect.x + 5, rtPrint.top + nToTop + nToTopHight * szText.cy, strText);
				}
				double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
				strText.Format(L"%.02fms", dTime);
				if (g_SysSet.nDefectDot == 0)
				{
					strText.Format(L"%.01fms", dTime);
				}
				szFont = pDc->GetOutputTextExtent(strText);
				pDc->SetTextColor(RGB(0, 0, 0));
				nToTopHight++;
				if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(ptDefect.x - szFont.cx + 5, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
				}
				else
				{
					pDc->TextOutW(ptDefect.x + 5, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
				}
				//桩缺陷
				rtDef.left = ptDefect.x - nDefLong;
				rtDef.right = ptDefect.x + nDefLong;
				SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i], bDir);
			}
			else
			{
				ptDefect.y = rtPrint.top + int(nToLeft + (dPos - nHPos) * dXGap);
				ptDefect.x = long(rtPrint.left + 2.2 * szNum.cy + nPileH);
				pDc->MoveTo(ptDefect);
				ptDefect.x = rtPrint.right - nToTop;
				pDc->LineTo(ptDefect);
				//桩长
				strDefect.Format(L"%.02fm", Ham_Info.WA_Info[0].fDefectPos[i]);
				if (g_SysSet.nDefectDot == 0)
				{
					strDefect.Format(L"%.01fm", Ham_Info.WA_Info[0].fDefectPos[i]);
				}
// 				strText = g_strDefectLevel[Ham_Info.WA_Info[0].chDefectLevel[i]];
// 				strText += g_strDefectType[Ham_Info.WA_Info[0].chDefectType[i]];

				strText = m_pData->GetDefectLevel(Ham_Info, i);
				strText += m_pData->GetDefectType(Ham_Info, i);
				//			strDefect += strText;
				szText = pDc->GetOutputTextExtent(strDefect);
				pDc->SetTextColor(g_SysSet.Cuver1clr);
				int nToTopHight = 0;	 //字体距离顶部的倍数
				if (ptDefect.y + 10 > rtPrint.top + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szText.cy + 5, ptDefect.y - szText.cx, strDefect);
				}
				else
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szText.cy + 5, ptDefect.y, strDefect);
				}
				double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
				strText.Format(L"%.02fms", dTime);
				if (g_SysSet.nDefectDot == 0)
				{
					strText.Format(L"%.01fms", dTime);
				}
				szFont = pDc->GetOutputTextExtent(strText);
				
				nToTopHight++;
				if (ptDefect.y + 10 > rtPrint.top + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szFont.cy + 5,  ptDefect.y - szFont.cx, strText);
				}
				else
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szFont.cy + 5, ptDefect.y, strText);
				}
				pDc->SetTextColor(RGB(0, 0, 0));
				//桩缺陷
				rtDef.top = ptDefect.y - nDefLong;
				rtDef.bottom = ptDefect.y + nDefLong;
				SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i], bDir);
			}
			

		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//波形2的缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
		{  //判断缺陷是否出界
			if (Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[1].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[1].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[1].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
			if (bDir)
			{
				ptDefect.x = rtPrint.left + int(nToLeft + (dPos - nHPos) * dXGap);
		//		ptDefect.y = rtPrint.bottom - 7 * nToTop;
				ptDefect.y = long(rtPrint.bottom - 2.2 * szNum.cy - nPileH);
				pDc->MoveTo(ptDefect);
				ptDefect.y = rtPrint.top + nToTop;
				pDc->LineTo(ptDefect);
				//桩长
				strDefect.Format(L"%.02fm", Ham_Info.WA_Info[1].fDefectPos[i]);
				if (g_SysSet.nDefectDot == 0)
				{
					strDefect.Format(L"%.01fm", Ham_Info.WA_Info[1].fDefectPos[i]);
				}
// 				strText = g_strDefectLevel[Ham_Info.WA_Info[1].chDefectLevel[i]];
// 				strText += g_strDefectType[Ham_Info.WA_Info[1].chDefectType[i]];

				strText = m_pData->GetDefectLevel(Ham_Info, i, 1);
				strText += m_pData->GetDefectType(Ham_Info, i, 1);
				//			strDefect += strText;
				szText = pDc->GetOutputTextExtent(strDefect);
				pDc->SetTextColor(g_SysSet.Cuver2clr);
				int nToTopHight = 2;	 //字体距离顶部的倍数
				if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(ptDefect.x - szText.cx + 5, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
				}
				else
				{
					pDc->TextOutW(ptDefect.x + 5, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
				}
				double dTime = (Ham_Info.WA_Info[1].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
				strText.Format(L"%.02fms", dTime);
				if (g_SysSet.nDefectDot == 0)
				{
					strText.Format(L"%.01fms", dTime);
				}
				szFont = pDc->GetOutputTextExtent(strText);
				pDc->SetTextColor(RGB(0, 0, 0));
				nToTopHight++;
				if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(ptDefect.x - szFont.cx + 5, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
				}
				else
				{
					pDc->TextOutW(ptDefect.x + 5, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
				}
				//桩缺陷
				rtDef.left = ptDefect.x - nDefLong;
				rtDef.right = ptDefect.x + nDefLong;
				SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i], bDir);
			}
			else
			{
				ptDefect.y = rtPrint.top + int(nToLeft + (dPos - nHPos) * dXGap);
				ptDefect.x = long(rtPrint.left + 2.2 * szNum.cy + nPileH);
				pDc->MoveTo(ptDefect);
				ptDefect.x = rtPrint.right - nToTop;
				pDc->LineTo(ptDefect);
				//桩长
				strDefect.Format(L"%.02fm", Ham_Info.WA_Info[1].fDefectPos[i]);
				if (g_SysSet.nDefectDot == 0)
				{
					strDefect.Format(L"%.01fm", Ham_Info.WA_Info[1].fDefectPos[i]);
				}
// 				strText = g_strDefectLevel[Ham_Info.WA_Info[1].chDefectLevel[i]];
// 				strText += g_strDefectType[Ham_Info.WA_Info[1].chDefectType[i]];
				strText = m_pData->GetDefectLevel(Ham_Info, i, 1);
				strText += m_pData->GetDefectType(Ham_Info, i, 1);

				//			strDefect += strText;
				szText = pDc->GetOutputTextExtent(strDefect);
				pDc->SetTextColor(g_SysSet.Cuver2clr);
				int nToTopHight = 0;	 //字体距离顶部的倍数
				if (ptDefect.y + 10 > rtPrint.top + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szText.cy + 5, ptDefect.y - szText.cx, strDefect);
				}
				else
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szText.cy + 5, ptDefect.y, strDefect);
				}
				double dTime = (Ham_Info.WA_Info[1].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
				strText.Format(L"%.02fms", dTime);
				if (g_SysSet.nDefectDot == 0)
				{
					strText.Format(L"%.01fms", dTime);
				}
				szFont = pDc->GetOutputTextExtent(strText);
				pDc->SetTextColor(RGB(0, 0, 0));
				nToTopHight++;
				if (ptDefect.y + 10 > rtPrint.top + nToLeft + nH_Wid - szText.cx)
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szFont.cy + 5, ptDefect.y - szFont.cx, strText);
				}
				else
				{
					pDc->TextOutW(rtPrint.right - nToTopHight * szFont.cy + 5, ptDefect.y, strText);
				}
				//桩缺陷
				rtDef.top = ptDefect.y - nDefLong;
				rtDef.bottom = ptDefect.y + nDefLong;
				SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i], bDir);
			}
			
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
// 
// 	pDc->SelectObject(OldFont);
// 	font.DeleteObject();
}

void CDrawWave::DrawPrintPileInfoPic(CDC *pDc, DT56_PILE_INFO Pile_Info, DT56_HAM_INFO Ham_Info, int nPileNo, int nHamNo, CRect rtPrint)
{
	int	nDescribe = 0;		//判断完整性评价
	WSDATA DataBuf = { 0 };
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);

	CString strNum(L"5");
	CSize szNum = 0;
	szNum = pDc->GetTextExtent(strNum);

	if (1 == g_ReportType.nDescribe)		//完整性评价
	{
		nDescribe = 1;
	}
	int nHPos = 0; //一个水平值

	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = rtPrint.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtPrint.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtPrint.Width() - nToLeft * 2;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = rtPrint.Height() - nToTop * nDescribe - szNum.cy * 3 / 2;	//画坐标系的时候 坐标高度
	int nPileH = nToTop * 2;					//桩的高度（宽度）
//	int nPileH = szNum.cy;					//桩的高度（宽度）
	int nWaveV_Hig = rtPrint.Height() - nPileH * 0 - szNum.cy * 2 - nToTop - nToTop * nDescribe;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = nToTop + nWaveV_Hig / 2;		//基准线位置

	int nrtPrintLeft = rtPrint.left;
	int nrtPrintTop = rtPrint.top;

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);
	//Y轴两点间距
	double dYGap = 1.0;
	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	//X轴两点间距
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom/* + Ham_Info.nMove_XZoom*/) * 1.0);
	dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
	//dXGap = (double)nH_Wid / ((Pile_Info.sHZoom + Ham_Info.nMove_XZoom/* + Ham_Info.nMove_XZoom*/) * 1.0);
	int nPileTop = 0;			//桩顶位置
	int nPileBottom = 0;		//桩底位置
	//桩顶位置判断
	if (0 == Ham_Info.sPileTopPos)
	{
		nPileTop = Ham_Info.sPileTopPos = 200;
	}
	else
	{
		nPileTop = Ham_Info.sPileTopPos;
	}

	//桩底 位置计算
	nPileBottom = (int)(nPileTop + (2.0 * Ham_Info.fPileLen * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
	//将桩顶桩底位置保存到成员变量中
	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	//	nHPos = 0;

	int nDataCnts = Pile_Info.sDataCnt;  //采样点数
	//对桩顶和桩底位置进行判断
	if (nPileTop >= nDataCnts)
	{
		nPileTop = nDataCnts - 2;
		nPileBottom = nDataCnts - 1;
	}
	else if (nPileBottom >= nDataCnts)
	{
		nPileBottom = nDataCnts - 1;
	}
	else{}

	//字体大小
	CSize szFont = pDc->GetTextExtent(L"轻微");
	//背景白色 透明
	// 	pDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	pDc->SetBkMode(TRANSPARENT);

	CRect rtPile; //获取桩区域
	rtPile.left = rtPrint.left + int(nToLeft + (nPileTop - nHPos) * dXGap);
	rtPile.top = rtPrint.bottom - szNum.cy * 2 - nPileH - nToTop * nDescribe;
	rtPile.right = rtPrint.left + int(nToLeft + (nPileBottom - nHPos) * dXGap);
	rtPile.bottom = rtPrint.bottom - szNum.cy * 2 - nToTop * nDescribe;
	if (rtPile.right > rtPrint.left + nH_Wid + nToLeft)
	{
		rtPile.right = rtPrint.left + nH_Wid + nToLeft;
	}

	//画桩
	pDc->FillSolidRect(rtPile, RGB(128, 138, 135));

	CRect rtPileDefect = rtPile;
	CRect rtPi = rtPile;
	//桩底类型
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		rtPi.left = rtPile.right - 13;

		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);

		CPoint ptP[3];
		ptP[0] = CPoint(rtPi.left, rtPi.top);
		ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
		ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{
		rtPi.left = rtPile.right - 10;
		rtPi.top = rtPile.top - 5;
		rtPi.bottom = rtPile.bottom + 5;
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
	CPoint pt = 0;
	double dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	if (g_WaveShowMode == WAVE_SHOW_V)
	{
		//PS_DOT点线
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);
		//画桩头
		pt.x = rtPile.left;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = rtPrint.top + nBaseLine - int(g_nWaveResever * DataBuf[nPileTop] / dYGap * dHfe);
		pDc->LineTo(pt);

		//画桩尾
		pt.x = rtPile.right - 1;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = rtPrint.top + nBaseLine - int(g_nWaveResever * DataBuf[nPileBottom] / dYGap * dHfe);
		pDc->LineTo(pt);

		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	CString strStrings(L"");
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strStrings = g_LoadString(L"DW_28");
		pDc->DrawText(strStrings, rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
//		pDc->DrawText(L"加速度曲线", rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
	}
	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画竖坐标线
	pt.x = rtPrint.left + nToLeft;
	pt.y = rtPrint.bottom;
	pDc->MoveTo(pt);
	pt.y = rtPrint.top + 15;
	pDc->LineTo(pt);

	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 3, pt.y);
	ptArr[2] = CPoint(pt.x + 3, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = rtPrint.left + nToLeft;
	pt.y = rtPrint.bottom - szNum.cy * 3 / 2;
	pDc->MoveTo(pt);
	pt.x = rtPrint.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = rtPrint.left + nToLeft;
	pt.y = rtPrint.top + nBaseLine;
	pDc->MoveTo(pt);
	pt.x = rtPrint.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 3);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 3);
	pDc->Polygon(ptArr, 3);

	//画刻度
	//一平所占的长度（米）
// 	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
// 	dLen = (Pile_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(Ham_Info.fPileLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;
	int nPosX = 0;
	int nPosY = 0;
	CSize szText;
	for (int i = 0; i < nDataCnts; ++i)
	{
		dMarkLen = double(i * dGap);
		nSite = int(dMarkLen * 10);
		nStepStart = int((i + nPileTop - nHPos) * dXGap) + nrtPrintLeft + nToLeft;
		//如果出了坐标轴就不画了
		if (nStepStart > nrtPrintLeft + nToLeft + nH_Wid)
		{
			break;
		}
		if (nSite == nSiteBack)
		{
			continue;
		}
		nSiteBack = nSite;
		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
		{
			pDc->MoveTo(nStepStart, rtPrint.bottom - szNum.cy * 3 / 2);
			pDc->LineTo(nStepStart, rtPrint.bottom - szNum.cy);
			rtNum.SetRect(nStepStart - 10, rtPrint.bottom - szNum.cy, nStepStart + 10, rtPrint.bottom);

			if (g_AbscissaMode == ABSCISSA_TIME)
			{
				if (0 == nSite)
				{
					strText = L"0.0";
				}
				else
				{
					strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
				}
			}
			else //横坐标长度
			{
				strText.Format(L"%d", (int)dMarkLen);
			}

			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);

		}
		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
		{
			pDc->MoveTo(nStepStart, rtPrint.bottom - szNum.cy * 3 / 2);
			pDc->LineTo(nStepStart, rtPrint.bottom - szNum.cy - szNum.cy / 4);
		}

	}
	//横坐标单位 时间或者长度
	if (g_AbscissaMode == ABSCISSA_LEN)
	{
		strText = L"m";
	}
	else
	{
		strText = L"ms";
	}

	pDc->TextOutW(rtPrint.left + nToLeft + nH_Wid + szNum.cx, rtPrint.bottom - szNum.cy * 3 / 2, strText);

	//纵坐标单位 速度或者加速度
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strText = L"m/s²";
	}
	else
	{
		strText = L"cm/s";
	}
	pt = CPoint(rtPrint.left + nToLeft + 20, rtPrint.top + nToTop);

	pDc->TextOutW(pt.x, pt.y, strText);
	szText = pDc->GetTextExtent(L"m/s²");

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	if (0 == g_ReportType.nDefectPos)
	{
		return;
	}
	//画缺陷
	//波形1缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint ptDefect;
	CString strDefect;
	CRect rtDef = rtPileDefect;
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
		{	//判断缺陷是否出界
			if (Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[0].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[0].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));

			ptDefect.x = rtPrint.left + int(nToLeft + (dPos - nHPos) * dXGap);
			//	ptDefect.y = rtPrint.bottom - 7 * nToTop;
			ptDefect.y = long(rtPrint.bottom - 2.2 * szNum.cy - nPileH);
			pDc->MoveTo(ptDefect);
			ptDefect.y = rtPrint.top + nToTop;
			pDc->LineTo(ptDefect);
			//桩长
			strDefect.Format(L"%.02fm", Ham_Info.WA_Info[0].fDefectPos[i]);
			if (g_SysSet.nDefectDot == 0)
			{
				strDefect.Format(L"%.01fm", Ham_Info.WA_Info[0].fDefectPos[i]);
			}
// 			strText = g_strDefectLevel[Ham_Info.WA_Info[0].chDefectLevel[i]];
// 			strText += g_strDefectType[Ham_Info.WA_Info[0].chDefectType[i]];
			strText = m_pData->GetDefectLevel(Ham_Info, i, 0);
			strText += m_pData->GetDefectType(Ham_Info, i, 0);

			//			strDefect += strText;
			szText = pDc->GetTextExtent(strDefect);
			pDc->SetTextColor(g_SysSet.Cuver1clr);
			int nToTopHight = 0;	 //字体距离顶部的倍数
			if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szText.cx, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			if (g_SysSet.nDefectDot == 0)
			{
				strText.Format(L"%.01fms", dTime);
			}
			szFont = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(0, 0, 0));
			nToTopHight++;
			if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szFont.cx, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			//桩缺陷
			rtDef.left = ptDefect.x - 5;
			rtDef.right = ptDefect.x + 5;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i]);
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//波形2的缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
		{  //判断缺陷是否出界
			if (Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[1].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[1].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[1].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
			
			ptDefect.x = rtPrint.left + int(nToLeft + (dPos - nHPos) * dXGap);
			ptDefect.y = long(rtPrint.bottom - 2.2 * szNum.cy - nPileH);
			pDc->MoveTo(ptDefect);
			ptDefect.y = rtPrint.top + nToTop;
			pDc->LineTo(ptDefect);
			//桩长
			strDefect.Format(L"%.02fm", Ham_Info.WA_Info[1].fDefectPos[i]);
			if (g_SysSet.nDefectDot == 0)
			{
				strDefect.Format(L"%.01fm", Ham_Info.WA_Info[1].fDefectPos[i]);
			}
// 			strText = g_strDefectLevel[Ham_Info.WA_Info[1].chDefectLevel[i]];
// 			strText += g_strDefectType[Ham_Info.WA_Info[1].chDefectType[i]];
			strText = m_pData->GetDefectLevel(Ham_Info, i, 1);
			strText += m_pData->GetDefectType(Ham_Info, i, 1);
			//			strDefect += strText;
			szText = pDc->GetTextExtent(strDefect);
			pDc->SetTextColor(g_SysSet.Cuver2clr);
			int nToTopHight = 0;	 //字体距离顶部的倍数
			if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szText.cx, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, rtPrint.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			double dTime = (Ham_Info.WA_Info[1].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			if (g_SysSet.nDefectDot == 0)
			{
				strText.Format(L"%.01fms", dTime);
			}
			szFont = pDc->GetTextExtent(strText);
			
			nToTopHight++;
			if (ptDefect.x + 10 > rtPrint.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szFont.cx, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, rtPrint.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			pDc->SetTextColor(RGB(0, 0, 0));
			//桩缺陷
			rtDef.left = ptDefect.x - 5;
			rtDef.right = ptDefect.x + 5;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i]);
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawPrintReportType(CDC *pDc, CString strText, int &nPosX, int &nPosY, CRect &rtPrint, BOOL bDir)
{
//	int nWordNum = GetWordNum();

//	CFont	font, *fontOld = NULL;
	CSize szFont, szText;
	int nToLeft = 0;  //开始位置距离左侧位置
	double dBeiShu = 2.0;
	if (g_DrawPicType == Draw_ToolPic)
	{
		dBeiShu = 1.5;
	}
	CString strVal(L"");
	if (bDir)
	{
// 		font.CreateFont(nWordNum, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 		fontOld = pDc->SelectObject(&font);
		strVal = L"测试";
		szFont = pDc->GetOutputTextExtent(strVal);
		nToLeft = szFont.cx / 4; //半个字空隙
		szText = pDc->GetOutputTextExtent(strText);
		if (szText.cx + nPosX - rtPrint.left >= rtPrint.Width()) //超过画框宽度 则另起一行
		{
			rtPrint.top = rtPrint.top + long(szFont.cy * dBeiShu);
			nPosX = rtPrint.left + nToLeft;
			nPosY = int(rtPrint.top + (szFont.cy * dBeiShu - szFont.cy) / 2);
			//画文字底部横线
			pDc->MoveTo(rtPrint.left, rtPrint.top + int(szFont.cy * dBeiShu));
			pDc->LineTo(rtPrint.right, rtPrint.top + int(szFont.cy * dBeiShu));
		}
		//写文字
		pDc->TextOutW(nPosX, nPosY, strText);
		//画竖线
		if (nPosX + szText.cx + nToLeft - rtPrint.left > rtPrint.Width())
		{
			nPosX = rtPrint.right;
		}
		else 
		{
			//画文字尾部竖线
			pDc->MoveTo(nPosX + szText.cx + nToLeft, rtPrint.top);
			pDc->LineTo(nPosX + szText.cx + nToLeft, rtPrint.top + int(szFont.cy * dBeiShu));
			//重新定位nPosX
			nPosX += int(szText.cx + nToLeft * dBeiShu);
		}
	}
	else
	{
// 		font.CreateFont(nWordNum, 0, 2700, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("微软雅黑"));
// 		fontOld = pDc->SelectObject(&font);
		strVal = L"测试";
		szFont = pDc->GetOutputTextExtent(strVal);
		nToLeft = szFont.cx / 4; //半个字空隙
		szText = pDc->GetOutputTextExtent(strText);
		if (szText.cx + nPosY - rtPrint.top >= rtPrint.Height())
		{
			rtPrint.right = rtPrint.right - long(szFont.cy * dBeiShu);
			nPosX = int(rtPrint.right - (szFont.cy * dBeiShu - szFont.cy) / 2);
			nPosY = rtPrint.top + nToLeft;

			pDc->MoveTo(rtPrint.right - int(szFont.cy * dBeiShu), rtPrint.top);
			pDc->LineTo(rtPrint.right - int(szFont.cy * dBeiShu), rtPrint.bottom);
		}
		//写文字
		pDc->TextOutW(nPosX, nPosY, strText);
		//画竖线
		if (nPosY + szText.cx + nToLeft - rtPrint.top > rtPrint.Height())
		{
			nPosY = rtPrint.bottom;
		}
		else 
		{
			//画文字尾部竖线
			int nDirw = 10;
			if (g_DrawPicType == Draw_ToolPic)
			{
				nDirw = 0;
			}
			pDc->MoveTo(rtPrint.right - nDirw, nPosY + nToLeft + szText.cx);
			pDc->LineTo(rtPrint.right - int(szFont.cy * dBeiShu), nPosY + nToLeft + szText.cx);
			//重新定位nPosX
			nPosY += int(szText.cx + nToLeft * dBeiShu);
		}
	}
// 	pDc->SelectObject(fontOld);
// 	font.DeleteObject();
}

void CDrawWave::AddPoint(CPoint pt, int nBaseLine, int &nCnt, VEC_PT &ptFillOne, VEC2_PT &ptFill)
{
	if (pt.y < nBaseLine)
	{
		ptFillOne.push_back(pt);
		nCnt++;
	}
	else if (pt.y == nBaseLine)
	{
		if (nCnt != 0)
		{
			ptFillOne.push_back(pt);
			ptFill.push_back(ptFillOne);
			ptFillOne.clear();
			nCnt = 0;
		}
		else
		{
			ptFillOne.clear();
			ptFillOne.push_back(pt);
		}		
	}
	else
	{
		if (nCnt != 0)
		{
			pt.x = (nBaseLine - ptFillOne.at(ptFillOne.size() - 1).y) * (pt.x - ptFillOne.at(ptFillOne.size() - 1).x) / (pt.y - ptFillOne.at(ptFillOne.size() - 1).y) + ptFillOne.at(ptFillOne.size() - 1).x;
			pt.y = nBaseLine;
			ptFillOne.push_back(pt);
			ptFill.push_back(ptFillOne);
			ptFillOne.clear();
			nCnt = 0;
		}
		else
		{
			ptFillOne.clear();
			pt.y = nBaseLine;
			pt.x += 1;
			ptFillOne.push_back(pt);
		}
	}
}

void CDrawWave::DrawFillWave(CDC *pDc, VEC2_PT ptFill)
{
	CPoint  *pPoint = NULL;
	CBrush brush, *pOldBrush = NULL;
	brush.CreateSolidBrush(RGB(0, 0, 0));
	pOldBrush = pDc->SelectObject(&brush);

	int nCnt = (int)ptFill.size();
	int nCntOne = 0;
	for (int i = 0; i < nCnt; ++i)
	{
		nCntOne = (int)ptFill.at(i).size();
		pPoint = new CPoint[nCntOne];
		for (int j = 0; j < nCntOne; ++j)
		{
			pPoint[j] = ptFill.at(i).at(j);
		}
		pDc->Polygon(pPoint, nCntOne);
		if (pPoint != NULL)
		{
			delete[]pPoint;
			pPoint = NULL;
		}
	}
	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();
}

void CDrawWave::GetDataBuf(WSDATA &DataBuf, WAVE_BACK Waveback, WAVE_SHOW_MODE WaveMode, int nPileNo, int HamNo, int nWaveNo)
{
	memset(DataBuf, 0, sizeof(double)* WAVES_SITE_4096);
	if (nWaveNo > 1)
	{
		return;
	}
	if (Waveback == Ave_Wave || HamNo == AVG_WAVE_NO)
	{
		if (WaveMode == WAVE_SHOW_A)
		{
			memcpy(DataBuf, m_pData->m_AcceDataAvg[nWaveNo][nPileNo], sizeof(double)* WAVES_SITE_4096);
		}
		else
		{
			memcpy(DataBuf, m_pData->m_SpeedDataAvg[nWaveNo][nPileNo], sizeof(double)* WAVES_SITE_4096);
		}
	}
	else
	{
		if (WaveMode == WAVE_SHOW_A)
		{
			memcpy(DataBuf, m_pData->m_AcceData[nWaveNo][nPileNo][HamNo],
				sizeof(double)* WAVES_SITE_4096);
		}
		else
		{
			memcpy(DataBuf, m_pData->m_SpeedData[nWaveNo][nPileNo][HamNo],
				sizeof(double)* WAVES_SITE_4096);
		}
	}
}

void CDrawWave::GetFreqDataBuf(WSDATA &DataBuf, int nPileNo, int HamNo, int nWaveNo)
{
	if (g_WaveView == WAVE_FREQ)
	{
		if (HamNo == AVG_WAVE_NO)
		{
			memcpy(DataBuf, m_pData->m_FreqDataAvg[nWaveNo][nPileNo], sizeof(double)* WAVES_SITE_4096);
		}
		else
		{
			memcpy(DataBuf, m_pData->m_FreqData[nWaveNo][nPileNo][HamNo], sizeof(double)* WAVES_SITE_4096);
		}	
	}
}

void CDrawWave::GetWaveMaxValue(DT56_HAM_INFO Ham_Info, double &dMax1, double &dMax2)
{
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		if (g_CoordLocked.bLocked)
		{
			dMax1 = g_CoordLocked.dAMaxY;
			dMax2 = g_CoordLocked.dAMaxY;
		}
		else
		{
			dMax1 = dMax1 < Ham_Info.dWaveAMax[0] ? Ham_Info.dWaveAMax[0] : dMax1;
			dMax2 = dMax2 < Ham_Info.dWaveAMax[1] ? Ham_Info.dWaveAMax[1] : dMax2;

			dMax1 = dMax1 < abs(Ham_Info.dWaveAMin[0]) ? abs(Ham_Info.dWaveAMin[0]) : dMax1;
			dMax2 = dMax2 < abs(Ham_Info.dWaveAMin[1]) ? abs(Ham_Info.dWaveAMin[1]) : dMax2;
		}
	}
	else
	{
		if (g_CoordLocked.bLocked)
		{
			dMax1 = g_CoordLocked.dVMaxY;
			dMax2 = g_CoordLocked.dVMaxY;
		}
		else
		{
			dMax1 = dMax1 < Ham_Info.dWaveVMax[0] ? Ham_Info.dWaveVMax[0] : dMax1;
			dMax2 = dMax2 < Ham_Info.dWaveVMax[1] ? Ham_Info.dWaveVMax[1] : dMax2;

			dMax1 = dMax1 < abs(Ham_Info.dWaveVMin[0]) ? abs(Ham_Info.dWaveVMin[0]) : dMax1;
			dMax2 = dMax2 < abs(Ham_Info.dWaveVMin[1]) ? abs(Ham_Info.dWaveVMin[1]) : dMax2;
		}
	}
}

//获取桩底点数
// int CDrawWave::GetPileBottomPoints(DT56_HAM_INFO &Ham_Info, DT56_PILE_INFO &Pile_Info)
// {
// 	int nPileBottom = (int)(Ham_Info.sPileTopPos + (2.0 * Ham_Info.fPileLen * g_nFrq[Pile_Info.sCaiYangFreq]) / (Ham_Info.nWaveSpeed * 1.0));
// 	if (nPileBottom < Ham_Info.sPileTopPos)
// 	{
// 		nPileBottom = Ham_Info.sPileTopPos + 1;
// 	}
// 	if (nPileBottom > WAVES_SITE_4096)
// 	{
// 		nPileBottom = WAVES_SITE_4096 - 1;
// 	}
// 	return nPileBottom;
// }

//画桩
void CDrawWave::DrawPileRect(CDC *pDc, CRect &rtPile, double dXGap, int nPileTop, int nPileBottom, int nHPos, DT56_HAM_INFO &Ham_Info, int MoveState)
{
	CString strStrings(L"");
	CString strText(L"");
	CSize szFont;
	CRect rt = rtPile;

	//qzg 2020.9.10 
	rtPile.left = int((nPileTop - nHPos) * dXGap + rt.left);
	rtPile.right = int((nPileBottom - nHPos + 1) * dXGap + rt.left);

//	rtPile.left = (nPileTop - nHPos) * dXGap + rt.left;
//	rtPile.right = (nPileBottom - nHPos) * dXGap + rt.left;

	if (rtPile.right > rt.right)
	{
		rtPile.right = rt.right;
	}

	CRect rtTextPile = rtPile;

	if (MoveState == 3)
	{
		//移动桩
		pDc->FillSolidRect(rtPile, RGB(128, 0, 64));
		strStrings = g_LoadString(L"DW_29");
		strText.Format(L"%.02fm", Ham_Info.fPileLen);
		strText = strStrings + strText;
//		strText.Format(L"桩长=%.02fm", Ham_Info.fPileLen);
		szFont = pDc->GetTextExtent(strText);
//		CRect rtTextPile = rtPile;
		rtTextPile.left = rtPile.right + 5;
		rtTextPile.right = rtTextPile.left + szFont.cx + 2;
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->DrawText(strText, rtTextPile, DT_CENTER | DT_NOCLIP);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else
	{
		if (g_WaveView != WAVE_NORMAL)
		{
			pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
			strText.Format(L"%.02fm", Ham_Info.fPileLen);
			szFont = pDc->GetTextExtent(strText);
			rtTextPile.left = rtPile.right + 5;
			rtTextPile.right = rtTextPile.left + szFont.cx + 2;
			pDc->DrawText(strText, rtTextPile, DT_CENTER | DT_NOCLIP);
		}		
	}

	//加速度标志
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strStrings = g_LoadString(L"DW_28");
		pDc->DrawText(strStrings, rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
		//		pDc->DrawText(L"加速度曲线", rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
	}
}

//移动写速度数据
void CDrawWave::DrawMoveSpeedData(CDC *pDc, DT56_HAM_INFO &Ham_Info, int MoveState)
{
	if (MoveState == 4)
	{
		CString strStrings(L"");
		CString strText(L"");

		strStrings = g_LoadString(L"DW_30");
		strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
		strText = strStrings + strText;
//		strText.Format(L"波速=%dm/s", Ham_Info.nWaveSpeed);
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->TextOutW(m_ptMouse.x + 2, m_ptMouse.y, strText);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
}

//画桩类型
void CDrawWave::DrawPileType(CDC *pDc, CRect rtPile, DT56_HAM_INFO &Ham_Info)
{
	CPen pen, *pOldPen = NULL;
	CRect rtPi = rtPile;

	//桩底类型
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		rtPi.left = rtPile.right - rtPile.Height() / 2;
		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);

		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		pOldPen = pDc->SelectObject(&pen);

		CPoint ptP[3];
		ptP[0] = CPoint(rtPi.left, rtPi.top);
		ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
		ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{
		rtPi.left = rtPile.right - rtPile.Height() / 2;
		rtPi.top = rtPile.top - rtPile.Height() / 8;
		rtPi.bottom = rtPile.bottom + rtPile.Height() / 8;
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
}

//画桩顶 和 桩尾标志线
void CDrawWave::DrawTopAndBottomFlagLine(CDC *pDc, CRect rtPile, WSDATA DataBuf, double dYGap, double dHfe, int nBaseLine, int nPileTop, int nPileBottom)
{
	if (g_WaveShowMode == WAVE_SHOW_V)
	{
		CPen pen, *pOldPen = NULL;
		CPoint pt = 0;
		//PS_DOT点线
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		pOldPen = pDc->SelectObject(&pen);
		//画桩头
		pt.x = rtPile.left;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = nBaseLine - int(g_nWaveResever * DataBuf[nPileTop] / dYGap * dHfe);
		pDc->LineTo(pt);

		//画桩尾
		pt.x = rtPile.right - 1;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = nBaseLine - int(g_nWaveResever * DataBuf[nPileBottom] / dYGap * dHfe);
		pDc->LineTo(pt);
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
	}
}

//画坐标系和刻度
void CDrawWave::DrawCoordinate(CDC *pDc, CRect rtKedu, int nBaseLine, double dXGap, double &dGap, int nHPos, DT56_HAM_INFO &Ham_Info, DT56_PILE_INFO &Pile_Info)
{
	CString strText(L"88");
	CSize szNum = pDc->GetOutputTextExtent(strText);
	CPen pen, *pOldPen = NULL;
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	pOldPen = pDc->SelectObject(&pen);
	CBrush brush, *pOldBrush = NULL;
	brush.CreateSolidBrush(RGB(180, 180, 180));
	pOldBrush = pDc->SelectObject(&brush);

	CPoint pt = 0;
	//画竖坐标线
	pt.x = rtKedu.left;
	pt.y = rtKedu.bottom;
	pDc->MoveTo(pt);
	pt.y = m_rtWave.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = rtKedu.left;
	pt.y = rtKedu.bottom;
	pDc->MoveTo(pt);
	pt.x = rtKedu.right;
	pDc->LineTo(pt);
	pDc->SelectObject(pOldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	pOldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = rtKedu.left;
	pt.y = nBaseLine;
	pDc->MoveTo(pt);
	pt.x = rtKedu.right;
	pDc->LineTo(pt);

	pDc->SelectObject(pOldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	pOldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 2);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 2);
	pDc->Polygon(ptArr, 3);

	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();
	//画刻度
	//一平所占的长度（米）
// 	double dLen = (Ham_Info.sHZoom - Ham_Info.sPileTopPos + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[Pile_Info.sCaiYangFreq]);
// 	dLen = (Pile_Info.sHZoom - Ham_Info.sPileTopPos + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[Pile_Info.sCaiYangFreq]);
	int nBigMark = GetXKeDu(Ham_Info.fPileLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[Pile_Info.sCaiYangFreq]); //单位长度
	m_dGap = dGap;
	vector<int> vKedu;
	vector<float> vfKedu;
	vector<int> vKeduLine;
	for (int i = 0; i < Pile_Info.sDataCnt; ++i)
	{
		dMarkLen = double(i * dGap);
		nSite = int(dMarkLen * 10);
		nStepStart = int((i + Ham_Info.sPileTopPos - nHPos) * dXGap) + rtKedu.left;
		//如果出了坐标轴就不画了
		if (nStepStart > rtKedu.right)
		{
			break;
		}
		if (nSite == nSiteBack)
		{
			continue;
		}
		nSiteBack = nSite;

		if ((0 == nSite % nBigMark)) //画长刻度线 并带刻度
		{
			pDc->MoveTo(nStepStart, rtKedu.bottom);
			pDc->LineTo(nStepStart, rtKedu.bottom - szNum.cy / 4);
			rtNum.SetRect(nStepStart - 10, rtKedu.top, nStepStart + 10, rtKedu.top + szNum.cy);
			if (g_AbscissaMode == ABSCISSA_TIME || g_WaveView == WAVE_NORMAL)
			{
				if (0 == nSite)
				{
					strText = L"0.0";
				}
				else
				{
					strText.Format(L"%.01f", (1 / (g_nFrq[Pile_Info.sCaiYangFreq] * 1.0)) * 1000 * i);
				}
			}
			else //横坐标长度
			{
				strText.Format(L"%d", (int)dMarkLen);
			}
			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);

			vKedu.push_back((int)dMarkLen);
			vfKedu.push_back(float(_ttof(strText)));
			vKeduLine.push_back(nStepStart);
		}
// 		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
// 		{
// 			pDc->MoveTo(nStepStart, rtKedu.bottom);
// 			pDc->LineTo(nStepStart, rtKedu.bottom - szNum.cy / 8);
// 		}
	}
	//补足未画出的刻度
	int nKeduGap = nBigMark / 10;
	int nGapCnt = 0;
	for (int i = 0; i < (int)vKedu.size() - 1; ++i)
	{
		int nGap = vKedu[i + 1] - vKedu[i];
		if (nGap != nKeduGap)
		{
			nGapCnt = nGap / nKeduGap;
			float fLineGap = float((vKeduLine[i + 1] - vKeduLine[i]) / nGapCnt);
			for (int k = 1; k < nGapCnt; ++k)
			{
				nStepStart = int(vKeduLine[i] + k * fLineGap);
				pDc->MoveTo(nStepStart, rtKedu.bottom);
				pDc->LineTo(nStepStart, rtKedu.bottom - szNum.cy / 4);
				rtNum.SetRect(nStepStart - 10, rtKedu.top, nStepStart + 10, rtKedu.top + szNum.cy);


				if (g_AbscissaMode == ABSCISSA_TIME || g_WaveView == WAVE_NORMAL)
				{
					float f1 = (vfKedu[i + 1] - vfKedu[i]) / nGapCnt;
					strText.Format(L"%.01f", vfKedu[i] + k * f1);
				}
				else //横坐标长度
				{
					strText.Format(L"%d", vKedu[i] + k * nKeduGap);
				}
				pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
			}
		}
	}

	//横坐标单位 时间或者长度
	if (g_AbscissaMode == ABSCISSA_LEN && g_WaveView != WAVE_NORMAL)
	{
		strText = L"m";
	}
	else
	{
		strText = L"ms";
	}
	szNum = pDc->GetOutputTextExtent(strText);
	pDc->TextOutW(rtKedu.right + 3, rtKedu.bottom - szNum.cy, strText);
	//纵坐标单位 速度或者加速度
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strText = L"m/s²";
	}
	else
	{
		strText = L"cm/s";
	}

	pt = CPoint(rtKedu.left + 10, int(m_rtWave.top + 5 + szNum.cy * 1.5));
	pDc->TextOutW(pt.x, pt.y, strText);
	pDc->SelectObject(pOldPen);
	pen.DeleteObject();
}

//写视图名称 返回文字区域
CRect CDrawWave::DrawViewName(CDC *pDc, CRect rtDraw)
{
	CString strStrings;
	CString strText(L"cm/s");
	CSize szText;
	szText = pDc->GetOutputTextExtent(strText);
	m_rtReturn.left = rtDraw.left + 10 + szText.cx + 15;
	m_rtReturn.top = m_rtWave.top + 5;
	strStrings = g_LoadString(L"DW_31");
	szText = pDc->GetTextExtent(strStrings);
//	szText = pDc->GetTextExtent(L"波形分析");
	m_rtReturn.right = m_rtReturn.left + szText.cx;
	m_rtReturn.bottom = m_rtReturn.top + szText.cy;

	if (g_WaveView == WAVE_FREQ) //频域分析
	{
 //		strStrings = g_LoadString(L"DW_33");
 //		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
	}
	else if (g_WaveView == WAVE_SINGLE) //单波分析
	{
		strStrings = g_LoadString(L"DW_34");
		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
	}
	else if (g_WaveView == WAVE_NORMAL) //常规分析
	{
		strStrings = g_LoadString(L"DW_35");
		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
	}
	else
	{
// 		strStrings = g_LoadString(L"DW_36");
// 		strStrings = L"";
// 		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
	}
	return m_rtReturn;
}

//画缺陷
void CDrawWave::DrawDefault(CDC *pDc, CRect rtDraw, CRect rtPile, DT56_HAM_INFO &Ham_Info, DT56_PILE_INFO &Pile_Info, double dXGap, double dGap, int nHPos, int nWaveNo)
{
	CPen pen, *OldPen = NULL;
	COLORREF clr;
	if (nWaveNo == 0)
	{
		clr = g_SysSet.Cuver1clr;
	}
	else if (nWaveNo == 1)
	{
		clr = g_SysSet.Cuver2clr;
	}
	else
	{
		return;
	}
	pen.CreatePen(PS_DASH, 1, clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint ptDefect;
	CString strDefect;
	CRect rtDef = rtPile;
	CString strText(L"");
	CSize szText;
	CSize szFont;

	for (int i = 0; i < Ham_Info.WA_Info[nWaveNo].chDefectCnt && i < 12; i++)
	{	//判断缺陷是否出界
		if (Ham_Info.WA_Info[nWaveNo].fDefectPos[i] > Ham_Info.fPileLen)
		{
			for (int j = i; j < Ham_Info.WA_Info[nWaveNo].chDefectCnt - 1; ++j)
			{
				Ham_Info.WA_Info[nWaveNo].fDefectPos[j] = Ham_Info.WA_Info[nWaveNo].fDefectPos[j + 1];
				Ham_Info.WA_Info[nWaveNo].chDefectLevel[j] = Ham_Info.WA_Info[nWaveNo].chDefectLevel[j + 1];
				Ham_Info.WA_Info[nWaveNo].chDefectType[j] = Ham_Info.WA_Info[nWaveNo].chDefectType[j + 1];
			}
			Ham_Info.WA_Info[0].chDefectCnt--;
			i--;
			continue;
		}
		double dPos = double(Ham_Info.sPileTopPos + (2.0 * Ham_Info.WA_Info[nWaveNo].fDefectPos[i] * g_nFrq[Pile_Info.sCaiYangFreq]) / (Ham_Info.nWaveSpeed * 1.0));
		//缺陷位置标志线
		ptDefect.x = int(rtDraw.left + (dPos - nHPos) * dXGap);
		ptDefect.y = rtPile.top;
		pDc->MoveTo(ptDefect);
		ptDefect.y = rtDraw.top;
		pDc->LineTo(ptDefect);
		//桩长
		strDefect = L"";
		if (g_sysInfo.nCheckShow)
		{
			strDefect.Format(L"%.02fm", Ham_Info.WA_Info[nWaveNo].fDefectPos[i]);
			if (g_SysSet.nDefectDot == 0)
			{
				strDefect.Format(L"%.01fm", Ham_Info.WA_Info[nWaveNo].fDefectPos[i]);
			}
		}

		strText = strDefect;
// 		if (Ham_Info.WA_Info[nWaveNo].chDefectLevel[i] < sizeof(g_strDefectLevel) / sizeof(g_strDefectLevel[0]))
// 		{
// 			strText += g_strDefectLevel[Ham_Info.WA_Info[nWaveNo].chDefectLevel[i]];
// 		}
// 		if (Ham_Info.WA_Info[nWaveNo].chDefectType[i] < sizeof(g_strDefectType) / sizeof(g_strDefectType[0]))
// 		{
// 			strText += g_strDefectType[Ham_Info.WA_Info[nWaveNo].chDefectType[i]];
// 		}
		strText += m_pData->GetDefectLevel(Ham_Info, i, nWaveNo);
		strText += m_pData->GetDefectType(Ham_Info, i, nWaveNo);
		//			strDefect += strText;
		szText = pDc->GetTextExtent(strText);
		pDc->SetTextColor(clr);
		int nToTopHight = 0;	 //字体距离顶部的倍数
		if (ptDefect.x + 10 > rtDraw.right - szText.cx)
		{
			pDc->TextOutW(ptDefect.x - szText.cx + 5, rtDraw.top + nToTopHight * szText.cy, strText);
		}
		else
		{
			pDc->TextOutW(ptDefect.x + 5, rtDraw.top + nToTopHight * szText.cy, strText);
		}
		double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[Pile_Info.sCaiYangFreq] * 1.0)) * 1000;
		strText.Format(L"%.02fms", dTime);
		if (g_SysSet.nDefectDot == 0)
		{
			strText.Format(L"%.01fms", dTime);
		}
		szFont = pDc->GetTextExtent(strText);
		pDc->SetTextColor(clr);
		nToTopHight++;
		if (ptDefect.x + 10 > rtDraw.right - szText.cx)
		{
			pDc->TextOutW(ptDefect.x - szFont.cx + 5, rtDraw.top + nToTopHight * szFont.cy, strText);
		}
		else
		{
			pDc->TextOutW(ptDefect.x + 5, rtDraw.top + nToTopHight * szFont.cy, strText);
		}
		//桩缺陷
		rtDef.left = ptDefect.x - rtPile.Height() / 6;
		rtDef.right = ptDefect.x + rtPile.Height() / 6;
		SetDefect(pDc, rtDef, Ham_Info.WA_Info[nWaveNo].chDefectType[i]);
	}

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

//旋转定位 移动红色标志线
void CDrawWave::DrawRotateInfo(CDC *pDc, CRect rtDrawWave, int MoveState)
{
	CPen pen, *OldPen = NULL;

	if (g_bBtnRotateLocat && (MoveState == 1 || MoveState == 0))
	{
		if (m_ptLocatLine.x > rtDrawWave.left && m_ptLocatLine.x <= rtDrawWave.right)
		{
			pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(m_ptLocatLine.x, rtDrawWave.bottom);
			pDc->LineTo(m_ptLocatLine.x, rtDrawWave.top);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	else if (g_bBtnWaveRectSel &&  g_bBtnWaveRectSizeShow && (MoveState == 1 || MoveState == 0))
	{	//选定旋转区域
		pen.CreatePen(PS_SOLID, 2, RGB(55, 200, 21));
		OldPen = pDc->SelectObject(&pen);
		if (m_PtSec[0].x < rtDrawWave.left + 1)
		{
			m_PtSec[0].x = rtDrawWave.left + 1;
		}
		if (m_PtSec[0].x > rtDrawWave.right - 1)
		{
			m_PtSec[0].x = rtDrawWave.right - 1;
		}
		if (m_PtSec[1].x < rtDrawWave.left + 1)
		{
			m_PtSec[1].x = rtDrawWave.left + 1;
		}
		if (m_PtSec[1].x > rtDrawWave.right - 1)
		{
			m_PtSec[1].x = rtDrawWave.right - 1;
		}
		if (m_PtSec[0].x == m_PtSec[1].x)
		{
			pDc->MoveTo(m_PtSec[0].x, rtDrawWave.top * 2);
			pDc->LineTo(m_PtSec[0].x, rtDrawWave.bottom - rtDrawWave.top);
		}
		else
		{
			pDc->Rectangle(m_PtSec[0].x, rtDrawWave.top * 2, m_PtSec[1].x, rtDrawWave.bottom - rtDrawWave.top);
		}
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
}

//移动鼠标画线
void CDrawWave::DrawMouseLine(CDC *pDc, CRect rtDrawWave, DT56_HAM_INFO &Ham_Info, DT56_PILE_INFO &Pile_Info, double dXGap, double dGap, int nHPos, int MoveState)
{
	if (0 == MoveState/*g_WaveType == Ave_Wave || (g_WaveType == Normal_Wave && nNo == m_pData->m_nSelHamNo)*/)
	{
		if (m_ptMouse.x > rtDrawWave.left && m_ptMouse.x <= rtDrawWave.right)
		{
			double dPileLen = 0;
			CPen pen, *OldPen = NULL;
			CString strText(L"");
			CSize szText;
			CSize szFont;
			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, rtDrawWave.bottom);
			pDc->LineTo(m_ptMouse.x, rtDrawWave.top);

			if (g_WaveView == WAVE_NORMAL)
			{
				pDc->SelectObject(OldPen);
				pen.DeleteObject();
				return;
			}
			//移动桩长  qzg +1
			dPileLen = (double(m_ptMouse.x - rtDrawWave.left + 1) / dXGap - Ham_Info.sPileTopPos + nHPos) * dGap;
			if (dPileLen < 0)
			{
				dPileLen = 0;
			}
			strText.Format(L"%.02fm", dPileLen);
			szText = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(255, 0, 0));
			int nToTopHight = 2;	 //字体距离顶部的倍数
			if (m_ptMouse.x + 10 > rtDrawWave.right - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szText.cx + 5, rtDrawWave.top  + nToTopHight * szText.cy / 3, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x + 5, rtDrawWave.top + nToTopHight * szText.cy / 3, strText);
			}
			//移动时间 qzg +1
			double dTime = (double(m_ptMouse.x - rtDrawWave.left + 1) / dXGap - Ham_Info.sPileTopPos + nHPos) * (1 / (g_nFrq[Pile_Info.sCaiYangFreq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			szFont = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(0, 0, 0));
			nToTopHight++;
			if (m_ptMouse.x + 10 > rtDrawWave.right- szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szFont.cx + 5, rtDrawWave.top + nToTopHight * szFont.cy / 2, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x + 5, rtDrawWave.top + nToTopHight * szFont.cy / 2, strText);
			}

			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
}

//画常规分析中的t1-t4位置
void CDrawWave::DrawNormalTimePos(CDC *pDc, CRect rtDrawWave, DT56_HAM_INFO &Ham_Info, DT56_PILE_INFO &Pile_Info, double dXGap, int nHPos)
{
	CPen pen, *OldPen = NULL;

	float fTPos1 = 0, fTPos2 = 0, fTPos3 = 0, fTPos4 = 0;
	float fPreReq = float((1 / (g_nFrq[Pile_Info.sCaiYangFreq] * 1.0)) * 1000);
	m_fPreFreq = fPreReq;
	//4个T的频率占比
	fTPos1 = Ham_Info.WA_Info[0].ft[0] / fPreReq;
	fTPos4 = Ham_Info.WA_Info[0].ft[1] / fPreReq;
	fTPos2 = Ham_Info.WA_Info[1].ft[0] / fPreReq;
	fTPos3 = Ham_Info.WA_Info[1].ft[1] / fPreReq;

	if (fTPos1 >= fTPos2)
	{
		fTPos2 = fTPos1 + 1;
	}

	if (fTPos4 <= fTPos3)
	{
		fTPos4 = fTPos3 + 1;
	}

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	int nTPos = 0;
	int nWidT = 5;	//每个区域宽度是2个nWidT
	float fLen1 = 0;
	float fLen2 = 0;
	fLen1 = float((fTPos1 + Ham_Info.sPileTopPos - nHPos) * dXGap) + rtDrawWave.left;
	nTPos = int(fLen1);
	m_nT_PosX[0] = nTPos;
	pDc->MoveTo(nTPos, rtDrawWave.top);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[0].SetRect(nTPos - nWidT, rtDrawWave.top, nTPos + nWidT, m_rtWave.bottom);

	nTPos = int((fTPos4 + Ham_Info.sPileTopPos - nHPos) * dXGap) + rtDrawWave.left;
	m_nT_PosX[3] = nTPos;
	pDc->MoveTo(nTPos, rtDrawWave.top);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[3].SetRect(nTPos - nWidT, rtDrawWave.top, nTPos + nWidT, m_rtWave.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	nTPos = int((fTPos2 + Ham_Info.sPileTopPos - nHPos) * dXGap) + rtDrawWave.left;
	m_nT_PosX[1] = nTPos;
	pDc->MoveTo(nTPos, rtDrawWave.top);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[1].SetRect(nTPos - nWidT, rtDrawWave.top, nTPos + nWidT, m_rtWave.bottom);

	fLen2 = float((fTPos3 + Ham_Info.sPileTopPos - nHPos) * dXGap) + rtDrawWave.left;
	nTPos = int(fLen2);
	m_nT_PosX[2] = nTPos;
	pDc->MoveTo(nTPos, rtDrawWave.top);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[2].SetRect(nTPos - nWidT, rtDrawWave.top, nTPos + nWidT, m_rtWave.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawPile(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{
	WSDATA DataBuf = { 0 };
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);

	CFont font, *OldFont = NULL;
	//获取字体大小
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);
	CPen pen, *OldPen = NULL;				//定义画笔
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//计算一下一个数字的高度， 用于后面计算
	CString strNum = L"55";
	CSize szNum;
	szNum = pDc->GetOutputTextExtent(strNum);

	CString strText(L"");

	CRect rtDraw = 0;			//左侧画布区域
	CRect rtInfo = 0;			//右侧信息区域
	InitWaveRect(rtDraw, rtInfo, m_rtWave);
	m_nToLeft = rtDraw.left;


	CRect rtKedu = 0;			//横坐标画刻度区域
	CRect rtPile = 0;			//桩区域
	CRect rtDrawWave = 0;		//画波形区域
	//获取此区域大小
	GetDrawRect(rtKedu, rtPile, rtDrawWave, szNum, rtDraw);

	int nBaseLine = 0;			//波形基准线高度
//	nBaseLine = rtDrawWave.top + rtDrawWave.Height() / 2;
	nBaseLine = rtDrawWave.top + (rtPile.bottom - rtDrawWave.top) / 2;

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);

	double dYGap = 1.0;		//Y轴两点间距
	double dHfe = 1.0;		//Y轴缩放系数
	int nKeDuHig = 0;

	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	GetYGap(dYGap, dHfe, nKeDuHig, dMax, rtDrawWave, rtPile, nBaseLine, Ham_Info);
	m_dYGap = dYGap;
	m_dHfe = dHfe;

// 	//Y轴长度
// 	double dMaxLen = GetYLen(dMax, Pile_Info);
	//X轴两点间距
	int nPileBottom = 0;
	//nPileBottom =  GetPileBottomPoints(Ham_Info, Pile_Info);
	nPileBottom = m_pData->GetPileBottomPoints(Ham_Info, Pile_Info);
	double dXGap = GetXGap(rtDrawWave.Width(), Pile_Info, Ham_Info);
	m_dXGap = dXGap;
	m_dYGap = dYGap;

	//Y轴长度
// 	double dLen = GetYLen(dMax, Pile_Info);
// 	double dKeDu = GetKeDu(dLen, dHfe, Pile_Info);
	//起始点 可以为负数
	int nHPos = GetBeginPos(dXGap, rtDrawWave.Width(), Ham_Info);
	int nPileTop = 0;			//桩顶位置
	//桩底位置
	//桩顶位置判断
	nPileTop = Ham_Info.sPileTopPos;
	//桩底 位置计算

	//将桩顶桩底位置保存到成员变量中
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;

	pDc->SetBkMode(TRANSPARENT);
	//画桩
//	TRACE(L"dXGap=%.1f, nPileTop = %d, nPileBottom = %d, nHPos = %d\r\n", dXGap, nPileTop, nPileBottom, nHPos);
	DrawPileRect(pDc, rtPile, dXGap, nPileTop, nPileBottom, nHPos, Ham_Info, MoveState);

	m_rtPile = rtPile;
	//保存桩顶和桩底位置
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;
	m_nSpeedPosUp =  rtDraw.top;
	m_nSpeedPosDown = rtPile.top - 1;
	//移动波速 
	DrawMoveSpeedData(pDc, Ham_Info, MoveState);
	//画桩类型
	DrawPileType(pDc, rtPile, Ham_Info);
	//画桩顶 和 桩尾标志线
	DrawTopAndBottomFlagLine(pDc, rtPile, DataBuf, dYGap, dHfe, nBaseLine, nPileTop, nPileBottom);
	m_dHfe = dHfe;

	//画坐标系
	double dGap = 0; //单位长度
	DrawCoordinate(pDc, rtKedu, nBaseLine, dXGap, dGap, nHPos, Ham_Info, Pile_Info);
	m_dGap = dGap;
	
	//写各个视图名称 返回文字区域
	DrawViewName(pDc, rtDraw);
	//画缺陷
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		DrawDefault(pDc, rtDraw, rtPile, Ham_Info, Pile_Info, dXGap, dGap, nHPos, 0);
	}
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		DrawDefault(pDc, rtDraw, rtPile, Ham_Info, Pile_Info, dXGap, dGap, nHPos, 1);
	}

	//旋转定位 移动红色标志线
	DrawRotateInfo(pDc, rtDrawWave, MoveState);
	//鼠标移动画线
	DrawMouseLine(pDc, rtDrawWave, Ham_Info, Pile_Info, dXGap, dGap, nHPos, MoveState);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}


void CDrawWave::DrawPile_1(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{
// 	DrawPile_1(pDc, Pile_Info, Ham_Info, nPileNo, nHamNo, MoveState);
// 	return;
	/*
	WSDATA DataBuf = { 0 };
	//获取数据
	GetDataBuf(DataBuf, m_enWaveBack, g_WaveShowMode, nPileNo, nHamNo, 0);

	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);

	int nHPos = 0; //一个水平值
	
	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = m_rtWave.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = m_rtWave.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = m_rtWave.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = m_rtWave.Height() - 2 * nToTop;	//画坐标系的时候 坐标高度
	int nPileH = 3 * nToTop;					//桩的高度（宽度）
	if (g_WaveView == WAVE_SINGLE)
	{
		nPileH = nToTop;
	}
	int nWaveV_Hig = m_rtWave.Height() - nPileH - 6 * nToTop;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = 2 * nToTop + nWaveV_Hig / 2;		//基准线位置

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	double dMax = GetWaveMaxValue(Ham_Info);
	//Y轴两点间距
	double dYGap = 1.0;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	//X轴两点间距
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
// 	if (Ham_Info.nMove_XZoom < 0)
// 	{
// 		Ham_Info.nMove_XZoom = 0;
// 	}
// 	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom) * 1.0);
	double dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
	m_dXGap = dXGap;
	m_dYGap = dYGap;
	int nPileTop = 0;			//桩顶位置
	int nPileBottom = 0;		//桩底位置
	//桩顶位置判断
	if (0 == Ham_Info.sPileTopPos)
	{
		nPileTop = Ham_Info.sPileTopPos = 200;
	}
	else
	{
		nPileTop = Ham_Info.sPileTopPos;
	}

	
	//桩底 位置计算
	nPileBottom = (int)(nPileTop + (2.0 * Ham_Info.fPileLen * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
	if (nPileBottom < nPileTop)
	{
		nPileBottom = nPileTop = 0;
//		TRACE(L"桩底小于桩头/n");
	}
	//将桩顶桩底位置保存到成员变量中
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;
//	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
	nHPos = int((nPileTop * dXGap - (nH_Wid) / 8) / dXGap);

	//桩顶定位线
// 	int  nHPosLen = nH_Wid / 8;
// 	//桩顶前到左侧线间的点
// 	nHPos = nHPosLen / dXGap;
// 	if (nHPos > nPileTop)
// 	{
// 		nHPos = nPileTop;
// 		nHPosLen = nHPos * dXGap;
// 	}
// 	//左侧线外的点数
// 	nHPos = nPileTop - nHPos;

//	nHPos = 0;
// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	int nDataCnts = Pile_Info.sDataCnt;  //采样点数
	//对桩顶和桩底位置进行判断
	if (nPileTop >= nDataCnts)
	{
		nPileTop = nDataCnts - 2;
		nPileBottom = nDataCnts - 1;
	}
	else if (nPileBottom >= nDataCnts)
	{
		nPileBottom = nDataCnts - 1;
	}
	else{}

	//字体大小
	CSize szFont = pDc->GetTextExtent(L"轻微");
	//背景白色 透明
	// 	pDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	pDc->SetBkMode(TRANSPARENT);

	

	CRect rtPile; //获取桩区域
	rtPile.left = int(nToLeft + (nPileTop - nHPos) * dXGap);
	rtPile.top = m_rtWave.bottom - 3 * nToTop - nPileH;
	rtPile.right = int(nToLeft + (nPileBottom - nHPos) * dXGap);
	rtPile.bottom = m_rtWave.bottom - 3 * nToTop;
	if (g_WaveView == WAVE_SINGLE)
	{
		rtPile.top = m_rtWave.bottom - 2 * nToTop - nPileH;
		rtPile.bottom = m_rtWave.bottom - 2 * nToTop;
	}
	if (rtPile.right > nH_Wid + nToLeft)
	{
		rtPile.right = nH_Wid + nToLeft;
	}
	m_rtPile = rtPile;
	//画桩
	CString strStrings(L"");
	if (MoveState == 3)
	{
		//移动桩
		pDc->FillSolidRect(rtPile, RGB(128, 0, 64));
		strStrings = g_LoadString(L"DW_29");
		strText.Format(L"%.02fm", Ham_Info.fPileLen);
		strText = strStrings + strText;
//		strText.Format(L"桩长=%.02fm", Ham_Info.fPileLen);
		szFont = pDc->GetTextExtent(strText);
		CRect rtTextPile = rtPile;
		rtTextPile.left = rtPile.right + 5;
		rtTextPile.right = rtTextPile.left + szFont.cx + 2;
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->DrawText(strText, rtTextPile, DT_CENTER | DT_NOCLIP);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else{
		pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	}
	//移动写速度数据
	if (MoveState == 4)
	{
		strStrings = g_LoadString(L"DW_30");
		strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
		strText = strStrings + strText;
//		strText.Format(L"波速=%dm/s", Ham_Info.nWaveSpeed);
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->TextOutW(m_ptMouse.x + 2, m_ptMouse.y, strText);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	
	//保存桩顶和桩底位置
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;
	m_nSpeedPosUp = m_rtWave.top + nToTop;
	m_nSpeedPosDown = rtPile.top - 1;

	CRect rtPileDefect = rtPile;
	CRect rtPi = rtPile;
	//桩底类型
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		rtPi.left = rtPile.right - 10;
		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);
		
		CPoint ptP[3];
		ptP[0] = CPoint(rtPi.left, rtPi.top);
		ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
		ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{	
		rtPi.left = rtPile.right - 10;
		rtPi.top = rtPile.top - 5;
		rtPi.bottom = rtPile.bottom + 5;
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
	CPoint pt = 0;
	double dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	m_dYGap = dYGap;
	m_dHfe = dHfe;
	if (g_WaveShowMode == WAVE_SHOW_V)
	{
		//PS_DOT点线
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);
		//画桩头
		pt.x = rtPile.left;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = nBaseLine - int(g_nWaveResever * DataBuf[nPileTop] / dYGap * dHfe);
		pDc->LineTo(pt);

		//画桩尾
		pt.x = rtPile.right - 1;
		pt.y = rtPile.top;
		pDc->MoveTo(pt);
		pt.y = nBaseLine - int(g_nWaveResever * DataBuf[nPileBottom] / dYGap * dHfe);
		pDc->LineTo(pt);
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}

	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strStrings = g_LoadString(L"DW_28");
		pDc->DrawText(strStrings, rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
//		pDc->DrawText(L"加速度曲线", rtPile, DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_VCENTER);
	}
	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画竖坐标线
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom;
	pDc->MoveTo(pt);
	pt.y = m_rtWave.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom - nToTop;
	pDc->MoveTo(pt);
	pt.x = m_rtWave.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.top + nBaseLine;
	pDc->MoveTo(pt);
	pt.x = m_rtWave.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 2);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 2);
	pDc->Polygon(ptArr, 3);

	//画刻度
	//一平所占的长度（米）
	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(dLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;
	for (int i = 0; i < nDataCnts; ++i)
	{
		dMarkLen = double(i * dGap);
		nSite = int(dMarkLen * 10);
		nStepStart = int((i + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
		//如果出了坐标轴就不画了
		if (nStepStart > m_rtWave.left + nToLeft + nH_Wid)
		{
			break;
		}
		if (nSite == nSiteBack)
		{
			continue;
		}
		nSiteBack = nSite;
		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
		{
			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 5);
			rtNum.SetRect(nStepStart - 10, m_rtWave.bottom - nToTop - 20, nStepStart + 10, m_rtWave.bottom - nToTop);
			if (g_AbscissaMode == ABSCISSA_TIME)
			{
				if (0 == nSite)
				{
					strText = L"0.0";
				}
				else
				{
					strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
				}
			}
			else //横坐标长度
			{
				strText.Format(L"%d", (int)dMarkLen);
			}
			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
		}
		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
		{
			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 3);
		}

	}

	//横坐标单位 时间或者长度
	if (g_AbscissaMode == ABSCISSA_LEN)
	{
		strText = L"m";
	}
	else
	{
		strText = L"ms";
	}
	pDc->TextOutW(m_rtWave.left + nToLeft + nH_Wid + 3, m_rtWave.bottom - nToTop - 10, strText);
	//纵坐标单位 速度或者加速度
	if (g_WaveShowMode == WAVE_SHOW_A)
	{
		strText = L"m/s²";
	}
	else
	{
		strText = L"cm/s";
	}

	pt = CPoint(m_rtWave.left + nToLeft + 10, m_rtWave.top + 25);
	pDc->TextOutW(pt.x, pt.y, strText);
	CSize szText = pDc->GetTextExtent(L"m/s²");

	//获取返回按钮区域
//	CString strStrings(L"");
	m_rtReturn.left = pt.x + szText.cx + 10;
	m_rtReturn.top = pt.y;
	strStrings = g_LoadString(L"DW_31");
	szText = pDc->GetTextExtent(strStrings);
//	szText = pDc->GetTextExtent(L"波形分析");
	m_rtReturn.right = m_rtReturn.left + szText.cx;
	m_rtReturn.bottom = m_rtReturn.top + szText.cy;

// 	if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
// 	{
// 		pDc->SetTextColor(RGB(255, 0, 0));
// 		strStrings = g_LoadString(L"DW_32");
// 		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
// //		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"平均波形");
// 		pDc->SetTextColor(RGB(0, 0, 0));
// 	}
// 	else 
// 	{
		if (g_WaveView == WAVE_FREQ)
		{
			strStrings = g_LoadString(L"DW_33");
			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
//			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"频域分析");
		}
		else if (g_WaveView == WAVE_SINGLE)
		{
			strStrings = g_LoadString(L"DW_34");
			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
//			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"单波分析");
		}
		else if (g_WaveView == WAVE_NORMAL)
		{
			strStrings = g_LoadString(L"DW_35");
			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
//			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"常规分析");
		}
		else
		{
			strStrings = g_LoadString(L"DW_36");
			strStrings = L"";
			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
//			pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"波形分析");
		}
// 		if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
// 		{
// 		}
// 		else
// 		{
// 			strText.Format(L"%d", nHamNo + 1);
// 			strStrings = g_LoadString(L"DW_37");
// 			strText = strStrings + strText;
// 			strStrings = g_LoadString(L"DW_38");
// 			strText += strStrings;
// 			//		strText.Format(L"第%d锤", nHamNo + 1);
// 			szText = pDc->GetTextExtent(strText);
// 			pDc->TextOutW(m_rtWave.right - 3 * nToLeft + 10, m_rtWave.top + nToTop, strText);
// 		}

//	}
	
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画缺陷
	//波形1缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint ptDefect;
	CString strDefect;
	CRect rtDef = rtPileDefect;
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
		{	//判断缺陷是否出界
			if (Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[0].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[0].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
			ptDefect.y = m_rtWave.bottom - 7 * nToTop;
			pDc->MoveTo(ptDefect);
			ptDefect.y = m_rtWave.top + nToTop;
			pDc->LineTo(ptDefect);
			//桩长
			strDefect.Format(L"%.02fm", Ham_Info.WA_Info[0].fDefectPos[i]);
			strText = g_strDefectLevel[Ham_Info.WA_Info[0].chDefectLevel[i]];
			strText += g_strDefectType[Ham_Info.WA_Info[0].chDefectType[i]];
//			strDefect += strText;
			szText = pDc->GetTextExtent(strDefect);
			pDc->SetTextColor(g_SysSet.Cuver1clr);
			int nToTopHight = 0;	 //字体距离顶部的倍数
			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			szFont = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(0, 0, 0));
			nToTopHight++;
			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i]);
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//波形2的缺陷
	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
		{  //判断缺陷是否出界
			if (Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[1].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[1].chDefectCnt--;
				i--;
				continue;
			}
			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[1].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
			ptDefect.y = m_rtWave.bottom - 7 * nToTop;
			pDc->MoveTo(ptDefect);
			ptDefect.y = m_rtWave.top + nToTop;
			pDc->LineTo(ptDefect);
			//桩长
			strDefect.Format(L"%.02fm", Ham_Info.WA_Info[1].fDefectPos[i]);
			strText = g_strDefectLevel[Ham_Info.WA_Info[1].chDefectLevel[i]];
			strText += g_strDefectType[Ham_Info.WA_Info[1].chDefectType[i]];
			//			strDefect += strText;
			szText = pDc->GetTextExtent(strDefect);
			pDc->SetTextColor(g_SysSet.Cuver2clr);
			int nToTopHight = 2;	 //字体距离顶部的倍数
			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
			}
			double dTime = (Ham_Info.WA_Info[1].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			szFont = pDc->GetTextExtent(strText);
			
			nToTopHight++;
			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(ptDefect.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			pDc->SetTextColor(RGB(0, 0, 0));
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i]);
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	double dPileLen = 0;	//移动过程中的桩长
	//旋转定位时的红色标志线
	if (g_bBtnRotateLocat && (MoveState == 1 || MoveState == 0))
	{
		if (m_ptLocatLine.x > nToLeft && m_ptLocatLine.x <= m_rtWave.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(m_ptLocatLine.x, m_rtWave.bottom - 2 * nToTop);
			pDc->LineTo(m_ptLocatLine.x, m_rtWave.top + nToTop);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	else if (g_bBtnWaveRectSel &&  g_bBtnWaveRectSizeShow  && (MoveState == 1 || MoveState == 0))
	{	//选定旋转区域
		pen.CreatePen(PS_SOLID, 2, RGB(55, 200, 21));
		OldPen = pDc->SelectObject(&pen);
		if (m_PtSec[0].x < nToLeft + 1)
		{
			m_PtSec[0].x = nToLeft + 1;
		}
		if (m_PtSec[0].x > m_rtWave.left + nToLeft + nH_Wid - 1)
		{
			m_PtSec[0].x = m_rtWave.left + nToLeft + nH_Wid - 1;
		}
		if (m_PtSec[1].x < nToLeft + 1)
		{
			m_PtSec[1].x = nToLeft + 1;
		}
		if (m_PtSec[1].x > m_rtWave.left + nToLeft + nH_Wid - 1)
		{
			m_PtSec[1].x = m_rtWave.left + nToLeft + nH_Wid - 1;
		}
		if (m_PtSec[0].x == m_PtSec[1].x)
		{
			pDc->MoveTo(m_PtSec[0].x, m_rtWave.top + 3 * nToTop);
			pDc->LineTo(m_PtSec[0].x, m_rtWave.bottom - 7 * nToTop);
		}
		else
		{
			pDc->Rectangle(m_PtSec[0].x, m_rtWave.top + 3 * nToTop, m_PtSec[1].x, m_rtWave.bottom - 7 * nToTop);
		}
		
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	//鼠标移动
	if (0 == MoveState/*g_WaveType == Ave_Wave || (g_WaveType == Normal_Wave && nNo == m_pData->m_nSelHamNo))
	{
		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= m_rtWave.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_DASHDOT, 1, RGB(0,0,0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, m_rtWave.bottom - 2 * nToTop);
			pDc->LineTo(m_ptMouse.x, m_rtWave.top + nToTop);
			//移动桩长
			dPileLen = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * dGap;
			if (dPileLen < 0)
			{
				dPileLen = 0;
			}
			strText.Format(L"%.02fm", dPileLen);
			szText = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(255, 0, 0));
			int nToTopHight = 3;	 //字体距离顶部的倍数
			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
			}
			//移动时间
			double dTime = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			szFont = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(0, 0, 0));
			nToTopHight++;
			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}

			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	pDc->SelectObject(OldFont);
	font.DeleteObject();
	*/
}

//提取上行波数据
void CDrawWave::GetUpWaveData(int nPile, int nHam)
{
	float nt = 0;
	float nT1 = 0;
	float nT4 = 0;
	int nBeginT = 0; 
	int nEndT = 0;
	if (nHam == AVG_WAVE_NO)
	{
		nt = m_pData->m_vecAvgHam[nPile].WA_Info[1].ft[0] - m_pData->m_vecAvgHam[nPile].WA_Info[0].ft[0];
		nT1 = m_pData->m_vecAvgHam[nPile].WA_Info[0].ft[0];
		nT4 = m_pData->m_vecAvgHam[nPile].WA_Info[1].ft[1];
	}
	else
	{
		nt = m_pData->m_vvecHam[nPile][nHam].WA_Info[1].ft[0] - m_pData->m_vvecHam[nPile][nHam].WA_Info[0].ft[0];
		nT1 = m_pData->m_vvecHam[nPile][nHam].WA_Info[0].ft[0];
		nT4 = m_pData->m_vvecHam[nPile][nHam].WA_Info[1].ft[1];
	}
	int nT = int(nt / m_fPreFreq +0.5);
	nBeginT = int(nT1 / m_fPreFreq + 0.5);
	nEndT = int(nT4 / m_fPreFreq + 0.5);

//	nT = (int)nt;
	m_pData->GetUpWaveData(m_pData->m_UpWaveData, nPile, nHam, nT, nBeginT, nEndT, m_dYGap, m_dHfe);
}

void CDrawWave::DrawNormalUpWave(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int MoveState)
{
	//画白色背景
	pMemDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	pMemDc->SelectStockObject(NULL_BRUSH);

	if (!m_pData->SelectPileOrNot())
	{
		return;
	}
	if (nHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave ) //平均波形
	{
		DrawNormalUpWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, MoveState);
		//获取上行波数据
		GetUpWaveData(nPileNo, AVG_WAVE_NO);
	}
	else
	{
		DrawNormalUpWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, MoveState);
		//获取上行波数据
		GetUpWaveData(nPileNo, nHamNo);
	}
	
	pDc->BitBlt(0, 0, m_rtWave.Width(), m_rtWave.Height(), pMemDc, 0, 0, SRCCOPY);
// 	pDc->TransparentBlt(0, 0, m_rtWave.Width(), m_rtWave.Height(),
// 		pMemDc, 0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
}
//获取波形数据
void CDrawWave::GetNormalDataBuf(WSDATA &DataBuf, int nPileNo, int HamNo, int nWaveNo)
{
	if (g_WaveView == WAVE_NORMAL)
	{
		if (HamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			memcpy(DataBuf, m_pData->m_SpeedDataAvg[nWaveNo][nPileNo], sizeof(double)* WAVES_SITE_4096);
		}
		else
		{
			memcpy(DataBuf, m_pData->m_SpeedData[nWaveNo][nPileNo][HamNo], sizeof(double)* WAVES_SITE_4096);
		}
	}
}

void CDrawWave::DrawNormalUpWave(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{
	WSDATA DataBuf1 = { 0 };
	WSDATA DataBuf2 = { 0 };

	CFont font, *OldFont = NULL;
	//获取字体大小
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);
	CPen pen, *OldPen = NULL;				//定义画笔
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//计算一下一个数字的高度， 用于后面计算
	CString strNum = L"55";
	CSize szNum;
	szNum = pDc->GetOutputTextExtent(strNum);

	CString strText(L"");

	CRect rtDraw = 0;			//左侧画布区域
	CRect rtInfo = 0;			//右侧信息区域
	InitWaveRect(rtDraw, rtInfo, m_rtWave);
	m_nToLeft = rtDraw.left;


	CRect rtKedu = 0;			//横坐标画刻度区域
	CRect rtPile = 0;			//桩区域
	CRect rtDrawWave = 0;		//画波形区域
	//获取此区域大小
	GetDrawRect(rtKedu, rtPile, rtDrawWave, szNum, rtDraw);

	int nBaseLine = 0;			//波形基准线高度
	nBaseLine = rtDrawWave.top + rtDrawWave.Height() / 2;

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	double dMax1 = 0;
	double dMax2 = 0;
	GetWaveMaxValue(Ham_Info, dMax1, dMax2);
//	double dMax = GetWaveMaxValue(Ham_Info);

	double dYGap = 1.0;		//Y轴两点间距
	double dHfe = 1.0;		//Y轴缩放系数
	int nKeDuHig = 0;
	double dMax = 0;
	dMax = dMax1 > dMax2 ? dMax1 : dMax2;
	GetYGap(dYGap, dHfe, nKeDuHig, dMax, rtDrawWave, rtPile, nBaseLine, Ham_Info);
	m_dYGap = dYGap;
	m_dHfe = dHfe;

	//Y轴长度
	double dMaxLen = GetYLen(dMax, Pile_Info);
	//X轴两点间距
	double dXGap = GetXGap(rtDrawWave.Width(), Pile_Info, Ham_Info);
	m_dXGap = dXGap;
	m_dYGap = dYGap;

	//Y轴长度
	double dLen1 = GetYLen(dMax1, Pile_Info);
	double dLen2 = GetYLen(dMax2, Pile_Info);
	double dKeDu1 = GetKeDu(dLen1, dHfe, Pile_Info, 0);
	double dKeDu2 = GetKeDu(dLen2, dHfe, Pile_Info, 1);

// 	double dLen = GetYLen(dMax, Pile_Info);
// 	double dKeDu = GetKeDu(dLen, dHfe, Pile_Info);
	//起始点 可以为负数
	int nHPos = GetBeginPos(dXGap, rtDrawWave.Width(), Ham_Info);
	int nPileTop = 0;			//桩顶位置
	int nPileBottom = 0;		//桩底位置
	//桩顶位置判断
	nPileTop = Ham_Info.sPileTopPos;
	//桩底 位置计算
	//nPileBottom = GetPileBottomPoints(Ham_Info, Pile_Info);
	nPileBottom = m_pData->GetPileBottomPoints(Ham_Info, Pile_Info);
	//将桩顶桩底位置保存到成员变量中
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;

	pDc->SetBkMode(TRANSPARENT);
	//画桩
	DrawPileRect(pDc, rtPile, dXGap, nPileTop, nPileBottom, nHPos, Ham_Info, MoveState);
	m_rtPile = rtPile;
	//保存桩顶和桩底位置
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;
	m_nSpeedPosUp = rtDraw.top;
	m_nSpeedPosDown = rtPile.top - 1;
	//移动波速 
	DrawMoveSpeedData(pDc, Ham_Info, MoveState);
	//画桩类型
//	DrawPileType(pDc, rtPile, Ham_Info);
	//画桩顶 和 桩尾标志线
//	DrawTopAndBottomFlagLine(pDc, rtPile, DataBuf1, dYGap, dHfe, nBaseLine, nPileTop, nPileBottom);
	

	//画坐标系
	double dGap = 0; //单位长度
	DrawCoordinate(pDc, rtKedu, nBaseLine, dXGap, dGap, nHPos, Ham_Info, Pile_Info);
	m_dGap = dGap;

	//写各个视图名称 返回文字区域
	DrawViewName(pDc, rtDraw);

	//画报告按钮
	CRect rtReport;
	DrawReportBtn(pDc, rtReport, rtInfo, Ham_Info);
	m_rtReport = rtReport;

	//信息区域
	DrawBasicInfo(pDc, rtReport, rtInfo, Ham_Info, Pile_Info);
	//画序号
	CRect rtNo = DrawPileNo(pDc, rtDraw, Ham_Info, Pile_Info, nHamNo, 1);

	//画纵坐标最大值
	int nKeDuHig1 = 0;
	int nKeDuHig2 = 0;
	nKeDuHig1 = (int)(dMax1 / dYGap * dHfe);  //像素点数
	if (0 == nKeDuHig1)
	{
		nKeDuHig1 = int(0.3617 * rtDrawWave.Height());
	}

	nKeDuHig2 = (int)(dMax2 / dYGap * dHfe);  //像素点数
	if (0 == nKeDuHig2)
	{
		nKeDuHig2 = int(0.3617 * rtDrawWave.Height());
	}

	//画纵坐标最大值
	DrawMaxText(pDc, rtDraw, nBaseLine, nKeDuHig1, dKeDu1, nKeDuHig2, dKeDu2);
//	DrawMaxText(pDc, rtDraw, nBaseLine, nKeDuHig, dKeDu);

	//画波形
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		VEC2_PT ptFill;
		GetNormalDataBuf(DataBuf1, nPileNo, nHamNo, 0);
		
		DrawWaveLine(pDc, rtDraw, DataBuf1, m_nHPos, nBaseLine, dXGap, dYGap, dHfe, Pile_Info.sDataCnt, g_SysSet.Cuver1clr, ptFill);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
		{	//填充波形
			DrawFillWave(pDc, ptFill);
		}
	}

	//画波形2
	m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
	if (g_FileType == FILE_DOUBLE_SPEED && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		VEC2_PT ptFill;
		GetNormalDataBuf(DataBuf2, nPileNo, nHamNo, 1);
		DrawWaveLine(pDc, rtDraw, DataBuf2, m_nHPos, nBaseLine, dXGap, dYGap, dHfe, Pile_Info.sDataCnt, g_SysSet.Cuver2clr, ptFill);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
		{	//填充波形
			DrawFillWave(pDc, ptFill);
		}
	}
	//画常规分析中的t1-t4位置
	DrawNormalTimePos(pDc, rtDrawWave, Ham_Info, Pile_Info, dXGap, nHPos);

	//旋转定位 移动红色标志线
	DrawRotateInfo(pDc, rtDrawWave, MoveState);
	//鼠标移动画线
	DrawMouseLine(pDc, rtDrawWave, Ham_Info, Pile_Info, dXGap, dGap, nHPos, MoveState);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
}

void CDrawWave::DrawNormalUpWave_1(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{
	/*
// 	DrawNormalUpWave_1(pDc, Pile_Info, Ham_Info, nPileNo, nHamNo, MoveState);
// 	return;
	WSDATA DataBuf1 = { 0 };
	WSDATA DataBuf2 = { 0 };
	//获取数据
	GetNormalDataBuf(DataBuf1, nPileNo, nHamNo, 0);
	GetNormalDataBuf(DataBuf2, nPileNo, nHamNo, 1);

	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);

	int nHPos = 0; //一个水平值

	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = m_rtWave.Width() / 25;	//开始画位置距离左侧边框距离 
	m_nToLeft = nToLeft;
	int nToTop = m_rtWave.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = m_rtWave.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = m_rtWave.Height() - 2 * nToTop;	//画坐标系的时候 坐标高度
	int nPileH = 3 * nToTop;					//桩的高度（宽度）
	int nWaveV_Hig = m_rtWave.Height() - nPileH - 6 * nToTop;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = 2 * nToTop + nWaveV_Hig / 2;		//基准线位置

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	double dMax = GetWaveMaxValue(Ham_Info);
	//Y轴两点间距
	double dYGap = 1.0;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	if (nBaseLine + Ham_Info.nMove_YZoom < 5 * nToTop)
	{
		Ham_Info.nMove_YZoom = 5 * nToTop - nBaseLine;
	}
	//X轴两点间距
	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
	{
		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom) * 1.0);
	m_dXGap = dXGap;

 	int nPileTop = 0;			//桩顶位置
 	int nPileBottom = 0;		//桩底位置
 	//桩顶位置判断
	if (0 == Ham_Info.sPileTopPos)
	{
		nPileTop = Ham_Info.sPileTopPos = 200;
	}
	else
	{
		nPileTop = Ham_Info.sPileTopPos;
	}
 	//桩底 位置计算
 	nPileBottom = (int)(nPileTop + (2.0 * Ham_Info.fPileLen * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;

 	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	m_nHPos = nHPos;
 	int nDataCnts = Pile_Info.sDataCnt;  //采样点数


	//字体大小
	CSize szFont = pDc->GetTextExtent(L"轻微");
	//背景白色 透明
	// 	pDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);
	pDc->SetBkMode(TRANSPARENT);

// 	//画桩
// 	pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	CPoint pt = 0;
	double dHfe = pow(2, (Ham_Info.sVZoom - 49 + Ham_Info.nMove_YZoom) / 15.0);

	//移动写速度数据
	CString strStrings(L"");
	if (MoveState == 4)
	{
		strStrings = g_LoadString(L"DW_30");
		strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
		strText = strStrings + strText;
//		strText.Format(L"波速=%dm/s", Ham_Info.nWaveSpeed);
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->TextOutW(m_ptMouse.x + 2, m_ptMouse.y, strText);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
	OldPen = pDc->SelectObject(&pen);

	//画竖坐标线
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom;
	pDc->MoveTo(pt);
	pt.y = m_rtWave.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//波速位置上下限
	m_nSpeedPosUp = m_rtWave.top + nToTop;
	m_nSpeedPosDown = m_rtWave.bottom - nToTop;;
	//横坐标
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.bottom - nToTop;
	pDc->MoveTo(pt);
	pt.x = m_rtWave.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = m_rtWave.left + nToLeft;
	pt.y = m_rtWave.top + nBaseLine;
	pDc->MoveTo(pt);
	pt.x = m_rtWave.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 2);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 2);
	pDc->Polygon(ptArr, 3);

	//画刻度
	//一平所占的长度（米）
 	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
// 	int nBigMark = 10;		//大标记位置
// 	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	else if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	else
// 	{
// 		nBigMark = 100;
// 	}
// 
// 	nSamllMark = nBigMark / 5;  //5个小标记
// 	CRect rtNum = 0;			//用于写字时定义字的区域
// 	int nStepStart = 0;			//已经走的步长
// 	double dMarkLen = 0.0;
 	int  nSite = 0;				//当前位置
// 	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
// 	m_dGap = dGap;
// 	for (int i = 0; i < nDataCnts; ++i)
// 	{
// 		dMarkLen = double(i * dGap);
// 		nSite = int(dMarkLen * 10);
// 		nStepStart = int((i + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
// 		//如果出了坐标轴就不画了
// 		if (nStepStart > m_rtWave.left + nToLeft + nH_Wid)
// 		{
// 			break;
// 		}
// 		if (nSite == nSiteBack)
// 		{
// 			continue;
// 		}
// 		nSiteBack = nSite;
// 		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
// 		{
// 			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
// 			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 5);
// 			rtNum.SetRect(nStepStart - 10, m_rtWave.bottom - nToTop - 20, nStepStart + 10, m_rtWave.bottom - nToTop);
// 			if (0 == nSite)
// 			{
// 				strText = L"0.0";
// 			}
// 			else
// 			{
// 				strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
// 			}
// 			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
// 		}
// 		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
// 		{
// 			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
// 			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 3);
// 		}
// 	}
	//横坐标单位 时间
	strText = L"ms";
	pDc->TextOutW(m_rtWave.left + nToLeft + nH_Wid + 3, m_rtWave.bottom - nToTop - 10, strText);
	
	//桩序号
	CRect rtNo;
	rtNo = CRect(m_rtWave.left + nToLeft + 10, m_rtWave.top + 5,
		m_rtWave.left + nToLeft + 50, m_rtWave.top + 23);
	pDc->FillSolidRect(rtNo, RGB(255, 120, 120));
	if (Ham_Info.sHamNum == AVG_WAVE_NO || nHamNo == AVG_WAVE_NO)
	{
		strText.Format(L"Avg");
	}
	else
	{
		strText.Format(L"%d/%d", Ham_Info.sHamNum, Pile_Info.sHamCnts);
	}
	CSize szNo = pDc->GetTextExtent(strText);
	pDc->TextOutW(rtNo.left + rtNo.Width() / 2 - szNo.cx / 2,
		rtNo.top + rtNo.Height() / 2 - szNo.cy / 2, strText);

	//纵坐标单位 速度或者加速度
	strText = L"cm/s";
	pt = CPoint(m_rtWave.left + nToLeft + 10, m_rtWave.top + 25);
	pDc->TextOutW(pt.x, pt.y, strText);

	CSize szText = pDc->GetTextExtent(L"m/s²");

	//获取返回按钮区域
	m_rtReturn.left = pt.x + szText.cx + 10;
	m_rtReturn.top = pt.y;
	strStrings = g_LoadString(L"DW_31");
	szText = pDc->GetTextExtent(strStrings);
//	szText = pDc->GetTextExtent(L"波形分析");
	m_rtReturn.right = m_rtReturn.left + szText.cx;
	m_rtReturn.bottom = m_rtReturn.top + szText.cy;



// 	if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
// 	{
// 		pDc->SetTextColor(RGB(255, 0, 0));
// 		strStrings = g_LoadString(L"DW_32");
// 		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
// //		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"平均波形");
// 		pDc->SetTextColor(RGB(0, 0, 0));
// 	}
// 	else
// 	{
		strStrings = g_LoadString(L"DW_35");
		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, strStrings);
//		pDc->TextOutW(m_rtReturn.left, m_rtReturn.top, L"常规分析");
// 		if (m_enWaveBack == Ave_Wave || nHamNo == AVG_WAVE_NO)
// 		{
// 		}
// 		else
// 		{
// 			strText.Format(L"%d", nHamNo + 1);
// 			strStrings = g_LoadString(L"DW_37");
// 			strText = strStrings + strText;
// 			strStrings = g_LoadString(L"DW_38");
// 			strText += strStrings;
// 			//		strText.Format(L"第%d锤", nHamNo + 1);
// 			szText = pDc->GetTextExtent(strText);
// 			pDc->TextOutW(m_rtWave.right - 3 * nToLeft + 10, m_rtWave.top + nToTop, strText);
// 		}


//	}

	
	//写报告
	CRect rtReport = 0;
	CString strReport = L"√报告";
	strReport = g_LoadString(L"DW_0");
	CSize szReport = pDc->GetTextExtent(strReport);
	rtReport.right = m_rtWave.right - 20;
	rtReport.left = rtReport.right - szReport.cx;
	rtReport.top = m_rtWave.top + nToTop;
	rtReport.bottom = rtReport.top + szReport.cy;

	//左侧方框
	CRect rtRR;
	rtRR.right = rtReport.left - 2;
	rtRR.top = rtReport.top + rtReport.Height() / 6;
	rtRR.left = rtRR.right - rtReport.Height() * 5 / 6;
	rtRR.bottom = rtReport.bottom - rtReport.Height() / 6;
	pDc->Rectangle(rtRR);
	//报告区域
	m_rtReport = rtReport;
	m_rtReport.left = rtRR.left;
	if (1 == Ham_Info.chUsedByReport)
	{
		pDc->SetTextColor(RGB(255, 0, 0));
		pDc->DrawText(L"√", rtRR, DT_TOP | DT_CENTER);

		strStrings = g_LoadString(L"DW_1");
		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
//		pDc->DrawText(L"√报告", rtReport, DT_TOP | DT_RIGHT);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else
	{
		strStrings = g_LoadString(L"DW_1");
		pDc->DrawText(strStrings, rtReport, DT_TOP | DT_LEFT);
//		pDc->DrawText(L"报告", rtReport, DT_TOP | DT_RIGHT);
	}

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
// 	//画刷置黑
// 	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
// 	OldPen = pDc->SelectObject(&pen);
// 
// 	CPoint ptWord = CPoint(m_rtWave.right - 3 * nToLeft + 10, m_rtWave.top + nToTop + szReport.cy * 2);
// 	strStrings = g_LoadString(L"DW_2");
// 	strText.Format(L"%.02fm", Ham_Info.fPileLen);
// 	strText = strStrings + strText;
// //	strText.Format(L"桩长：%.02fm", Ham_Info.fPileLen);
// 	pDc->TextOutW(ptWord.x, ptWord.y, strText);
// 	ptWord.y += (szReport.cy + 3);
// 	pDc->MoveTo(ptWord);
// 	pDc->LineTo(m_rtWave.right - 20, ptWord.y);
// 
// 	ptWord.y += szReport.cy;
// 	strStrings = g_LoadString(L"DW_3");
// 	strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
// 	strText = strStrings + strText;
// //	strText.Format(L"波速：%dm/s", Ham_Info.nWaveSpeed);
// 	pDc->TextOutW(ptWord.x, ptWord.y, strText);
// 	ptWord.y += (szReport.cy + 3);
// 	pDc->MoveTo(ptWord);
// 	pDc->LineTo(m_rtWave.right - 20, ptWord.y);
// 
// 	ptWord.y += szReport.cy;
// 	strStrings = g_LoadString(L"DW_4");
// 	strText.Format(L"%d", Ham_Info.sExpEnlargeNum);
// 	strText = strStrings + strText;
// //	strText.Format(L"指数放大：%d", Ham_Info.sExpEnlargeNum);
// 	pDc->TextOutW(ptWord.x, ptWord.y, strText);
// 	ptWord.y += (szReport.cy + 3);
// 	pDc->MoveTo(ptWord);
// 	pDc->LineTo(m_rtWave.right - 20, ptWord.y);
// 
// 	ptWord.y += szReport.cy;
// 	strStrings = g_LoadString(L"DW_5");
// 	strText.Format(L"%d Hz", Ham_Info.nFilterLowFrq);
// 	strText = strStrings + strText;
// //	strText.Format(L"低通：%d Hz", Ham_Info.nFilterLowFrq);
// 	pDc->TextOutW(ptWord.x, ptWord.y, strText);
// 	ptWord.y += (szReport.cy + 3);
// 	pDc->MoveTo(ptWord);
// 	pDc->LineTo(m_rtWave.right - 20, ptWord.y);
// 
// 	ptWord.y += szReport.cy;
// 	strStrings = g_LoadString(L"DW_6");
// 	strText.Format(L"%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
// 	strText = strStrings + strText;
// //	strText.Format(L"采样频率：%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
// 	pDc->TextOutW(ptWord.x, ptWord.y, strText);
// 	ptWord.y += (szReport.cy + 3);
// 	pDc->MoveTo(ptWord);
// 	pDc->LineTo(m_rtWave.right - 20, ptWord.y);
// 
// 	pDc->SelectObject(OldPen);
// 	pen.DeleteObject();


	//画波形
//	double dLen;
	dLen = GetYLen(dMax, Pile_Info);
// 	if (g_WaveShowMode == WAVE_SHOW_V)		//速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8) / (32768 * 2 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * 3;
// 	}
// 	else			//加速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 2 * 100) * 3;
// 	}

	nSite = (int)(dMax / dYGap);  //像素点数
	if (0 == nSite)
	{
		nSite = int(0.3617 * nWaveV_Hig);
	}
	double dKeDu = (dLen * Pile_Info.fSensorS[0]) / 100.0;
	double dKeDu1 = (dLen * Pile_Info.fSensorS[1]) / 100.0;

	dKeDu = dKeDu > dKeDu1 ? dKeDu : dKeDu1;

	pt.x = m_rtWave.left + nToLeft;
	pt.y = nBaseLine - nSite;
	pDc->MoveTo(pt);
	pDc->LineTo(pt.x - 5, pt.y);

	strText.Format(L"%.02f", dKeDu);
	szText = pDc->GetTextExtent(strText);
	CRect rtText = 0;
	rtText.right = pt.x - 10;
	rtText.left = rtText.right - szText.cx;
	rtText.top = pt.y - szText.cy / 2;
	rtText.bottom = rtText.top + szText.cy;
	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
	strText = L"(max)";
	rtText.top += (szText.cy);
	rtText.bottom = rtText.top + szText.cy;
	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);

	//旋转定位时的红色标志线
	if (g_bBtnRotateLocat && (MoveState == 1 || MoveState == 0))
	{
		if (m_ptLocatLine.x > nToLeft && m_ptLocatLine.x <= m_rtWave.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(m_ptLocatLine.x, m_rtWave.bottom - 2 * nToTop);
			pDc->LineTo(m_ptLocatLine.x, m_rtWave.top + nToTop);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	else if (g_bBtnWaveRectSel && g_bBtnWaveRectSizeShow && (MoveState == 1 || MoveState == 0))
	{	//选定旋转区域
		pen.CreatePen(PS_SOLID, 2, RGB(55, 200, 21));
		OldPen = pDc->SelectObject(&pen);
		if (m_PtSec[0].x < nToLeft + 1)
		{
			m_PtSec[0].x = nToLeft + 1;
		}
		if (m_PtSec[0].x > m_rtWave.left + nToLeft + nH_Wid - 1)
		{
			m_PtSec[0].x = m_rtWave.left + nToLeft + nH_Wid - 1;
		}
		if (m_PtSec[1].x < nToLeft + 1)
		{
			m_PtSec[1].x = nToLeft + 1;
		}
		if (m_PtSec[1].x > m_rtWave.left + nToLeft + nH_Wid - 1)
		{
			m_PtSec[1].x = m_rtWave.left + nToLeft + nH_Wid - 1;
		}
		if (m_PtSec[0].x == m_PtSec[1].x)
		{
			pDc->MoveTo(m_PtSec[0].x, m_rtWave.top + 3 * nToTop);
			pDc->LineTo(m_PtSec[0].x, m_rtWave.bottom - 7 * nToTop);
		}
		else
		{
			pDc->Rectangle(m_PtSec[0].x, m_rtWave.top + 3 * nToTop, m_PtSec[1].x, m_rtWave.bottom - 7 * nToTop);
		}

		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}

	//绘制曲线
//	dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	double dXSite = nToLeft;
	double dYSite = 0.0;

// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	//画波形1
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	int nCntFill = 0;
	VEC_PT ptFillOne;
	VEC2_PT ptFill;
	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	m_dYGap = dYGap;
	m_dHfe = dHfe;
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap); 
		}
		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf1[m_nHPos] / dYGap * dHfe);
		pDc->MoveTo(pt);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
		{	//填充
			AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
		}
		for (int i = m_nHPos; i < Pile_Info.sDataCnt; ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
			}
			
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[0];
			pDc->LineTo(pt);
			if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_1)
			{	//填充
				AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
			}
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	//画波形2
	if (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL)
	{
		m_nHPos2 = nHPos + Ham_Info.nMoveL_R[1];
		dXSite = nToLeft;
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap);
		}
		pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf2[m_nHPos2] / dYGap * dHfe);
		pDc->MoveTo(pt);
		if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
		{	//填充
			AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
		}

		for (int i = m_nHPos2; i < Pile_Info.sDataCnt; ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf2[i] / dYGap * dHfe);
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf2[i] / dYGap * dHfe);
			}
			
			pt.x = (long)dXSite;
			pt.y = (long)dYSite - Ham_Info.nMoveU_D[1];
			pDc->LineTo(pt);
			if (g_bBtnFillWave && g_WaveOperate == WAVE_OPERATE_2)
			{	//填充
				AddPoint(pt, nBaseLine, nCntFill, ptFillOne, ptFill);
			}
			dXSite += dXGap;
		}
	}

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	if (g_bBtnFillWave)
	{	//填充波形
		DrawFillWave(pDc, ptFill);
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//画t1 - t4 位置
	float fTPos1 = 0, fTPos2 = 0, fTPos3 = 0, fTPos4 = 0;
	float fPreReq = float((1 / (g_nFrq[nFrq] * 1.0)) * 1000);
	m_fPreFreq = fPreReq;
	//4个T的频率占比
	fTPos1 = Ham_Info.WA_Info[0].ft[0] / fPreReq;
	fTPos4 = Ham_Info.WA_Info[0].ft[1] / fPreReq;
	fTPos2 = Ham_Info.WA_Info[1].ft[0] / fPreReq;
	fTPos3 = Ham_Info.WA_Info[1].ft[1] / fPreReq;

	if (fTPos1 >= fTPos2)
	{
//		fTPos1 = fTPos2 - 1;
		fTPos2 = fTPos1 + 1;
	}

	if (fTPos4 <= fTPos3)
	{
		fTPos4 = fTPos3 + 1;
	}

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	int nTPos = 0;
	int nWidT = 5;	//每个区域宽度是2个nWidT
	float fLen1 = 0;
	float fLen2 = 0;
	fLen1 = float((fTPos1 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos = int(fLen1);
	m_nT_PosX[0] = nTPos;
	pDc->MoveTo(nTPos, m_rtWave.top + nToTop);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[0].SetRect(nTPos - nWidT, m_rtWave.top + nToTop, nTPos + nWidT, m_rtWave.bottom);

	nTPos = int((fTPos4 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	m_nT_PosX[3] = nTPos;
	pDc->MoveTo(nTPos, m_rtWave.top + nToTop);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[3].SetRect(nTPos - nWidT, m_rtWave.top + nToTop, nTPos + nWidT, m_rtWave.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	nTPos = int((fTPos2 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	m_nT_PosX[1] = nTPos;
	pDc->MoveTo(nTPos, m_rtWave.top + nToTop);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[1].SetRect(nTPos - nWidT, m_rtWave.top + nToTop, nTPos + nWidT, m_rtWave.bottom);

	fLen2 = float((fTPos3 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos = int(fLen2);
	m_nT_PosX[2] = nTPos;
	pDc->MoveTo(nTPos, m_rtWave.top + nToTop);
	pDc->LineTo(nTPos, m_rtWave.bottom);
	m_rtTimeLine[2].SetRect(nTPos - nWidT, m_rtWave.top + nToTop, nTPos + nWidT, m_rtWave.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//根据是个T时间来计算桩
	
//	Ham_Info.nWaveSpeed = int((Pile_Info.fSensorH[1] - Pile_Info.fSensorH[0]) / (Ham_Info.WA_Info[1].ft[0] - Ham_Info.WA_Info[0].ft[0])* 1000);
//	Ham_Info.fPileLen = float(Ham_Info.WA_Info[1].ft[1] - Ham_Info.WA_Info[0].ft[0]) * Ham_Info.nWaveSpeed / 2000;

	//画刷置黑
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	CPoint ptWord = CPoint(m_rtWave.right - 3 * nToLeft + 10, m_rtWave.top + nToTop + szReport.cy * 2);
	strStrings = g_LoadString(L"DW_2");
	strText.Format(L"%.02fm", Ham_Info.fPileLen);
	strText = strStrings + strText;
	//	strText.Format(L"桩长：%.02fm", Ham_Info.fPileLen);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + 3);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += szReport.cy;
	strStrings = g_LoadString(L"DW_3");
	strText.Format(L"%dm/s", Ham_Info.nWaveSpeed);
	strText = strStrings + strText;
	//	strText.Format(L"波速：%dm/s", Ham_Info.nWaveSpeed);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + 3);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += szReport.cy;
	strStrings = g_LoadString(L"DW_4");
	strText.Format(L"%d", Ham_Info.sExpEnlargeNum);
	strText = strStrings + strText;
	//	strText.Format(L"指数放大：%d", Ham_Info.sExpEnlargeNum);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + 3);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += szReport.cy;
	strStrings = g_LoadString(L"DW_5");
	strText.Format(L"%d Hz", Ham_Info.nFilterLowFrq);
	strText = strStrings + strText;
	//	strText.Format(L"低通：%d Hz", Ham_Info.nFilterLowFrq);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + 3);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	ptWord.y += szReport.cy;
	strStrings = g_LoadString(L"DW_6");
	strText.Format(L"%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
	strText = strStrings + strText;
	//	strText.Format(L"采样频率：%d kHz", g_nFrq[Pile_Info.sCaiYangFreq] / 1000);
	pDc->TextOutW(ptWord.x, ptWord.y, strText);
	ptWord.y += (szReport.cy + 3);
	pDc->MoveTo(ptWord);
	pDc->LineTo(m_rtWave.right - 20, ptWord.y);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();


	//画刻度
	//一平所占的长度（米）
	dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(dLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	else if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	else if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;
	for (int i = 0; i < nDataCnts; ++i)
	{
		dMarkLen = double(i * dGap);
		nSite = int(dMarkLen * 10);
		nStepStart = int((i + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
		//如果出了坐标轴就不画了
		if (nStepStart > m_rtWave.left + nToLeft + nH_Wid)
		{
			break;
		}
		if (nSite == nSiteBack)
		{
			continue;
		}
		nSiteBack = nSite;
		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
		{
			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 5);
			rtNum.SetRect(nStepStart - 10, m_rtWave.bottom - nToTop - 20, nStepStart + 10, m_rtWave.bottom - nToTop);
			if (0 == nSite)
			{
				strText = L"0.0";
			}
			else
			{
				strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
			}
			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
		}
		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
		{
			pDc->MoveTo(nStepStart, m_rtWave.bottom - nToTop);
			pDc->LineTo(nStepStart, m_rtWave.bottom - nToTop - 3);
		}
	}
	//画缺陷
	//波形1缺陷
// 	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
// 	OldPen = pDc->SelectObject(&pen);
// 	CPoint ptDefect;
// 	CString strDefect;
// //	CRect rtDef = rtPileDefect;
// 	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
// 	{
// 		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
// 		{	//判断缺陷是否出界
// 			if (Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
// 			{
// 				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
// 				{
// 					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
// 					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
// 					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
// 				}
// 				Ham_Info.WA_Info[0].chDefectCnt--;
// 				i--;
// 				continue;
// 			}
// 			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[0].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
// 			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
// 			ptDefect.y = m_rtWave.bottom - 7 * nToTop;
// 			pDc->MoveTo(ptDefect);
// 			ptDefect.y = m_rtWave.top + nToTop;
// 			pDc->LineTo(ptDefect);
// 			//桩长
// 			strDefect.Format(L"%.02f", Ham_Info.WA_Info[0].fDefectPos[i]);
// 			strText = g_strDefectLevel[Ham_Info.WA_Info[0].chDefectLevel[i]];
// 			strText += g_strDefectType[Ham_Info.WA_Info[0].chDefectType[i]];
// 			//			strDefect += strText;
// 			szText = pDc->GetTextExtent(strDefect);
// 			pDc->SetTextColor(g_SysSet.Cuver1clr);
// 			int nToTopHight = 0;	 //字体距离顶部的倍数
// 			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(ptDefect.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
// 			}
// 			double dTime = (Ham_Info.WA_Info[0].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
// 			strText.Format(L"%.02fms", dTime);
// 			szFont = pDc->GetTextExtent(strText);
// 			pDc->SetTextColor(RGB(0, 0, 0));
// 			nToTopHight++;
// 			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(ptDefect.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}
// 			//桩缺陷
// 			rtDef.left = ptDefect.x - m_nDefectWD;
// 			rtDef.right = ptDefect.x + m_nDefectWD;
// 			SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i]);
// 
// 		}
// 	}
// 	pDc->SelectObject(OldPen);
// 	pen.DeleteObject();
	//波形2的缺陷
// 	pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
// 	OldPen = pDc->SelectObject(&pen);
// 	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
// 	{
// 		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
// 		{  //判断缺陷是否出界
// 			if (Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
// 			{
// 				for (int j = i; j < Ham_Info.WA_Info[1].chDefectCnt - 1; ++j)
// 				{
// 					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
// 					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
// 					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
// 				}
// 				Ham_Info.WA_Info[1].chDefectCnt--;
// 				i--;
// 				continue;
// 			}
// 			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[1].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
// 			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
// 			ptDefect.y = m_rtWave.bottom - 7 * nToTop;
// 			pDc->MoveTo(ptDefect);
// 			ptDefect.y = m_rtWave.top + nToTop;
// 			pDc->LineTo(ptDefect);
// 			//桩长
// 			strDefect.Format(L"%.02f", Ham_Info.WA_Info[1].fDefectPos[i]);
// 			strText = g_strDefectLevel[Ham_Info.WA_Info[1].chDefectLevel[i]];
// 			strText += g_strDefectType[Ham_Info.WA_Info[1].chDefectType[i]];
// 			//			strDefect += strText;
// 			szText = pDc->GetTextExtent(strDefect);
// 			pDc->SetTextColor(g_SysSet.Cuver2clr);
// 			int nToTopHight = 2;	 //字体距离顶部的倍数
// 			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(ptDefect.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strDefect);
// 			}
// 			double dTime = (Ham_Info.WA_Info[1].fDefectPos[i] / dGap) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
// 			strText.Format(L"%.02fms", dTime);
// 			szFont = pDc->GetTextExtent(strText);
// 			
// 			nToTopHight++;
// 			if (ptDefect.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(ptDefect.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(ptDefect.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}
// 			pDc->SetTextColor(RGB(0, 0, 0));
// 			//桩缺陷
// 			rtDef.left = ptDefect.x - m_nDefectWD;
// 			rtDef.right = ptDefect.x + m_nDefectWD;
// 			SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i]);
// 		}
// 	}
// 	pDc->SelectObject(OldPen);
// 	pen.DeleteObject();
// 	//旋转定位时的红色标志线
// 	if (g_bBtnRotateLocat && (MoveState == 1 || MoveState == 0))
// 	{
// 		if (m_ptLocatLine.x > nToLeft && m_ptLocatLine.x <= m_rtWave.left + nToLeft + nH_Wid)
// 		{
// 			pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
// 			OldPen = pDc->SelectObject(&pen);
// 			pDc->MoveTo(m_ptLocatLine.x, m_rtWave.bottom - 2 * nToTop);
// 			pDc->LineTo(m_ptLocatLine.x, m_rtWave.top + nToTop);
// 			pDc->SelectObject(OldPen);
// 			pen.DeleteObject();
// 		}
// 	}
// 	else if (g_bBtnWaveRectSel && g_bBtnWaveRectSizeShow  && (MoveState == 1 || MoveState == 0))
// 	{	//选定旋转区域
// 		pen.CreatePen(PS_SOLID, 2, RGB(55, 200, 21));
// 		OldPen = pDc->SelectObject(&pen);
// 		if (m_PtSec[0].x < nToLeft + 1)
// 		{
// 			m_PtSec[0].x = nToLeft + 1;
// 		}
// 		if (m_PtSec[0].x > m_rtWave.left + nToLeft + nH_Wid - 1)
// 		{
// 			m_PtSec[0].x = m_rtWave.left + nToLeft + nH_Wid - 1;
// 		}
// 		if (m_PtSec[1].x < nToLeft + 1)
// 		{
// 			m_PtSec[1].x = nToLeft + 1;
// 		}
// 		if (m_PtSec[1].x > m_rtWave.left + nToLeft + nH_Wid - 1)
// 		{
// 			m_PtSec[1].x = m_rtWave.left + nToLeft + nH_Wid - 1;
// 		}
// 		if (m_PtSec[0].x == m_PtSec[1].x)
// 		{
// 			pDc->MoveTo(m_PtSec[0].x, m_rtWave.top + 3 * nToTop);
// 			pDc->LineTo(m_PtSec[0].x, m_rtWave.bottom - 7 * nToTop);
// 		}
// 		else
// 		{
// 			pDc->Rectangle(m_PtSec[0].x, m_rtWave.top + 3 * nToTop, m_PtSec[1].x, m_rtWave.bottom - 7 * nToTop);
// 		}
// 
// 		pDc->SelectObject(OldPen);
// 		pen.DeleteObject();
// 	}
	//鼠标移动
	double dPileLen = 0; //移动桩长

	if (0 == MoveState)
	{
		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= m_rtWave.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, m_rtWave.bottom - 2 * nToTop);
			pDc->LineTo(m_ptMouse.x, m_rtWave.top + nToTop);

			//移动桩长
			dPileLen = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * dGap;
			if (dPileLen < 0)
			{
				dPileLen = 0;
			}
			strText.Format(L"%.02fm", dPileLen);
			szText = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(255, 0, 0));
			int nToTopHight = 3;	 //字体距离顶部的倍数
			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
			}
			//移动时间
			double dTime = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
			strText.Format(L"%.02fms", dTime);
			szFont = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(0, 0, 0));
			nToTopHight++;
			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
			}

			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	pDc->SelectObject(OldFont);
	font.DeleteObject();
	*/
}

int CDrawWave::GetXKeDu(float fPileLen)
{
	int nBigMark = 10;		//大标记位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	else if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	else if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}
// 	if (dLen > 40.0)
// 	{
// 		nBigMark = 100;
// 	}
// 	else if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	else if(dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}

	if (fPileLen >= 30)
	{
		nBigMark = 50;
	}
	else if (fPileLen > 5)
	{
		nBigMark = 20;
	}
	else
	{
		nBigMark = 10;
	}
	return nBigMark;
}

//波形显示部分两点之间的间距
double CDrawWave::GetXGap(int nH_Wid, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info)
{
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	//nH_Wid = nH_Wid * 7 / 8;
	int nWid = Ham_Info.sHZoom + Ham_Info.nMove_XZoom;
	//nWid = Pile_Info.sHZoom + Ham_Info.nMove_XZoom;
	//int pileBotton = GetPileBottomPoints(Ham_Info, Pile_Info);
	int pileBotton = m_pData->GetPileBottomPoints(Ham_Info, Pile_Info);

	pileBotton += Ham_Info.nMove_XZoom;
	if (0 == nWid)
	{
		nWid = 1;
	}
// 	if (nWid < pileBotton)
// 	{
// 		nWid = pileBotton;
// 	}
	//nWid -= Ham_Info.sPileTopPos;
	double dXGap = 1;

// 	float fLen = Pile_Info.fPrePileLen;
// 	if (fLen < 0.0001 && fLen > -0.0001)
// 	{
// 		dXGap = (double)nH_Wid / (nWid  * 1.0);
// 	}
// 	else
// 	{
// 		dXGap = (double)(nH_Wid * Ham_Info.fPileLen) / (nWid * fLen);
// 	}
// 	if (pileBotton - Ham_Info.sPileTopPos != 0)
// 	{
// 		dXGap = (double)nH_Wid *Ham_Info.fPileLen / (2.0 * Pile_Info.fPrePileLen * (pileBotton - Ham_Info.sPileTopPos));
// 	}	
	if (pileBotton - Ham_Info.sPileTopPos > 0)
	{
		dXGap = (double)nH_Wid *Ham_Info.fPileLen / (2.0 * Pile_Info.fPrePileLen * (pileBotton - Ham_Info.sPileTopPos));
	}
	else{
		dXGap = (double)nH_Wid *Ham_Info.fPileLen / (2.0 * Pile_Info.fPrePileLen * (pileBotton));
	}
	if (dXGap < 0)
	{
		dXGap = 1;
	}
	return dXGap;
}

//获取波形Y轴长度
double CDrawWave::GetYLen(double dMax, DT56_PILE_INFO &Pile_Info)
{
	double dLen = 0;
	int nNum = 1;
	//信号源数值，DT52要减半
	if (g_nYiqiType == DT52)
	{
		nNum = 2;
	}
	if (g_WaveShowMode == WAVE_SHOW_V)		//速度
	{
//		dLen = (dMax * 2.5 * 9.8) / (32768 * 2 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * 3;
//		dLen = (dMax * 2.5 * 9.8) / (32768 * 1 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * (10.1 / 3.3);
//		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 1 * g_nFrq[Pile_Info.sCaiYangFreq]) * (10.1 / 3.3);
		
// 		if (Pile_Info.sZengYi <= 0)
// 		{
// 			dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 1 * g_nFrq[Pile_Info.sCaiYangFreq]) * (10.1 / 3.3);
// 		}
// 		else
// 		{
// 			long nValue = (32768.0 * 1 * g_nFrq[Pile_Info.sCaiYangFreq] * Pile_Info.sZengYi);
// 			dLen = (dMax * 2.5 * 9.8 * 1000) / nValue * (10.1 / 3.3);
// 		}

		//dLen = (dMax * 2.5 * 9.8) / (32768 * 1 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * (10.1 / 3.3);
		int nZy = ModifyZengyi(Pile_Info.sZengYi);
		long long nValue = (32768.0 * nNum * g_nFrq[Pile_Info.sCaiYangFreq] * nZy);
		dLen = (dMax * 2.5 * 9.8 * 1000) / nValue * (10.1 / 3.3);
	}
	else			//加速度
	{
		int nZy = ModifyZengyi(Pile_Info.sZengYi);
//		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 2 * 100) * 3;
		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * nNum * 100 * nZy) * (10.1 / 3.3);
	}
	return dLen;
}

void CDrawWave::DrawNormalDownWave(CDC *pDc, CDC * pMemDc, int nPileNo, int nHamNo, int MoveState)
{
	pMemDc->FillSolidRect(0, 0, m_rtWave.Width(), m_rtWave.Height(), COLOR_AVG_WAVE_BACK);

	if (!m_pData->SelectPileOrNot())
	{
		return;
	}
	if (nHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave) //平均波形
	{
		DrawNormalDownWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vecAvgHam.at(nPileNo), nPileNo, nHamNo, MoveState);
	}
	else
	{
		DrawNormalDownWave(pMemDc, m_pData->m_vecPile.at(nPileNo),
			m_pData->m_vvecHam[nPileNo].at(nHamNo), nPileNo, nHamNo, MoveState);
	}

	pDc->BitBlt(0, m_rtFreqDwon.top, m_rtWave.Width(), m_rtWave.Height(), pMemDc, 0, 0, SRCCOPY);
}

void CDrawWave::DrawNormalDownWave(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{

	WSDATA DataBuf1 = { 0 };
	WSDATA DataBuf2 = { 0 };
	//获取数据
	GetNormalDataBuf(DataBuf1, nPileNo, nHamNo, 0);
	GetNormalDataBuf(DataBuf2, nPileNo, nHamNo, 1);

	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);

	int nHPos = 0; //一个水平值

	CRect rtUp = m_rtWave;			//波形上方区域
	rtUp.bottom = m_rtWave.Height() * 2 / 3;
	CRect rtDown = m_rtWave;		//下方波形区域
	rtDown.top = rtUp.bottom;

	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = rtDown.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtDown.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtDown.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = rtDown.Height() - 2 * nToTop;	//画坐标系的时候 坐标高度
	int nPileH = 3 * nToTop;					//桩的高度（宽度）
	int nWaveV_Hig = rtDown.Height() - nPileH - 6 * nToTop;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine = rtDown.top + 2 * nToTop + nWaveV_Hig / 2;		//基准线位置

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
	//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax = m_pData->GetUpWaveMaxValue(Pile_Info.sDataCnt);
	//Y轴两点间距
	double dYGap = 1.0;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	//X轴两点间距
// 	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
// 	{
// 		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
// 	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom + Ham_Info.nMove_XZoom) * 1.0);
	dXGap = GetXGap(nH_Wid, Pile_Info, Ham_Info);
//	dXGap = (double)nH_Wid / ((Pile_Info.sHZoom + Ham_Info.nMove_XZoom + Ham_Info.nMove_XZoom) * 1.0);

	int nPileTop = 0;			//桩顶位置
	int nPileBottom = 0;		//桩底位置
	//桩顶位置判断
	if (0 == Ham_Info.sPileTopPos)
	{
		nPileTop = Ham_Info.sPileTopPos = 200;
	}
	else
	{
		nPileTop = Ham_Info.sPileTopPos;
	}
	//桩底 位置计算
	//nPileBottom = GetPileBottomPoints(Ham_Info, Pile_Info);
	nPileBottom = m_pData->GetPileBottomPoints(Ham_Info, Pile_Info);
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;

	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
	int nDataCnts = Pile_Info.sDataCnt;  //采样点数

	//对桩顶和桩底位置进行判断
	if (nPileTop >= nDataCnts)
	{
		nPileTop = nDataCnts - 2;
		nPileBottom = nDataCnts - 1;
	}
	else if (nPileBottom >= nDataCnts)
	{
		nPileBottom = nDataCnts - 1;
	}
	else{}

	//字体大小
	CSize szFont = pDc->GetTextExtent(L"轻微");
	pDc->SetBkMode(TRANSPARENT);

	CRect rtPile; //获取桩区域
	rtPile.left = int(nToLeft + (nPileTop - nHPos) * dXGap);
	rtPile.top = rtDown.bottom - 3 * nToTop - nPileH;
	rtPile.right = int(nToLeft + (nPileBottom - nHPos) * dXGap);
	rtPile.bottom = rtDown.bottom - 3 * nToTop;
	if (rtPile.right > nH_Wid + nToLeft)
	{
		rtPile.right = nH_Wid + nToLeft;
	}
	// 	//根据4个T时间来计算桩;
	rtPile.left = m_nT_PosX[0];
	rtPile.right = m_nT_PosX[3];

	m_rtPile = rtPile;

	//画桩
	CString strStrings(L"");
	//	pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	if (MoveState == 3)
	{
		//移动桩
		pDc->FillSolidRect(rtPile, RGB(128, 0, 64));
		strStrings = g_LoadString(L"DW_29");
		strText.Format(L"%.02fm", Ham_Info.fPileLen);
		strText = strStrings + strText;
		//		strText.Format(L"桩长=%.02fm", Ham_Info.fPileLen);
		szFont = pDc->GetTextExtent(strText);
		CRect rtTextPile = rtPile;
		rtTextPile.left = rtPile.right + 5;
		rtTextPile.right = rtTextPile.left + szFont.cx + 2;
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->DrawText(strText, rtTextPile, DT_CENTER | DT_NOCLIP);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else{
		pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	}

	//保存桩顶和桩底位置
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;
	m_nSpeedPosUp = m_rtWave.top + nToTop;
	m_nSpeedPosDown = rtPile.top - 1;
	//桩位置上下限
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;

	CRect rtPileDefect = rtPile;
	CRect rtPi = rtPile;
	//桩底类型
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		rtPi.left = rtPile.right - 13;
		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);

		CPoint ptP[3];
		ptP[0] = CPoint(rtPi.left, rtPi.top);
		ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
		ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{
		rtPi.left = rtPile.right - 10;
		rtPi.top = rtPile.top - 5;
		rtPi.bottom = rtPile.bottom + 5;
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
	double dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	//写上行波文字
	strText = g_LoadString(L"MB_106");
	szFont = pDc->GetTextExtent(strText);
	CRect rtWaveUpText;
	rtWaveUpText.top = rtDown.top + 2;
	rtWaveUpText.left = rtDown.left + 2;
	rtWaveUpText.right = rtWaveUpText.left + szFont.cx + 3;
	rtWaveUpText.bottom = rtWaveUpText.top + szFont.cy + 3;
	CBrush brush, *pOldBrush = NULL;
	brush.CreateSolidBrush(RGB(180, 0, 0));
	pOldBrush = pDc->SelectObject(&brush);
	pDc->FillRect(rtWaveUpText, &brush);
	pDc->DrawText(strText, rtWaveUpText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	//	pDc->TextOutW(rtWaveUpText.left, rtWaveUpText.top, strText);
	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();


	//画上行波形
	double dXSite = nToLeft;
	double dYSite = 0;
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint pt = 0;
	//	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	m_nHPos = nHPos;

	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap);
			pt.y = (long)nBaseLine;
		}
		else
		{
			pt.y = (long)nBaseLine - (int)(m_pData->m_UpWaveData[m_nHPos] / dYGap * dHfe);
		}
		
		pDc->MoveTo(pt);
		for (int i = m_nHPos; i < Pile_Info.sDataCnt; ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine;
				dXSite += dXGap;
				continue;
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * m_pData->m_UpWaveData[i] / dYGap * dHfe);
			}

			pt.x = (long)dXSite;
			pt.y = (long)dYSite/* - Ham_Info.nMoveU_D[0]*/;
			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//保存缺陷位置和长度
	vector<DEFECT_POS> vecDefectPos1;
	vector<DEFECT_POS> vecDefectPos2;
	//画桩缺陷
	int nT2T3Gap = m_nT_PosX[2] - m_nT_PosX[1];  //t2 t3间距
	CRect rtDef = rtPileDefect;
	CPoint ptDefect;
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
		{
			//判断缺陷是否出界
			if (Ham_Info.WA_Info[0].fDefectPos[i] <= Pile_Info.fSensorH[1] || Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[0].chDefectCnt--;
				i--;
				continue;
			}
			ptDefect.x = long((Ham_Info.WA_Info[0].fDefectPos[i] - Pile_Info.fSensorH[1]) * (float)nT2T3Gap / (Ham_Info.fPileLen - Pile_Info.fSensorH[1]));
			ptDefect.x += m_nT_PosX[1];

			DEFECT_POS defect_pos;
			defect_pos.nPos = ptDefect.x;
			defect_pos.fLen = Ham_Info.WA_Info[0].fDefectPos[i];
			vecDefectPos1.push_back(defect_pos);
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i]);
		}
	}
	//波形2缺陷
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
		{//判断缺陷是否出界
			if (Ham_Info.WA_Info[1].fDefectPos[i] <= Pile_Info.fSensorH[1] || Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[1].chDefectCnt--;
				i--;
				continue;
			}
			ptDefect.x = long((Ham_Info.WA_Info[1].fDefectPos[i] - Pile_Info.fSensorH[1]) * (float)nT2T3Gap / (Ham_Info.fPileLen - Pile_Info.fSensorH[1]));
			ptDefect.x += m_nT_PosX[1];

			DEFECT_POS defect_pos;
			defect_pos.nPos = ptDefect.x;
			defect_pos.fLen = Ham_Info.WA_Info[1].fDefectPos[i];
			vecDefectPos2.push_back(defect_pos);
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i]);
		}
	}


	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	brush.CreateSolidBrush(RGB(180, 180, 180));
	pOldBrush = pDc->SelectObject(&brush);

	//画竖坐标线
	pt.x = rtDown.left + nToLeft;
	pt.y = rtDown.bottom;
	pDc->MoveTo(pt);
	pt.y = rtDown.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = rtDown.left + nToLeft;
	pt.y = rtDown.bottom - nToTop;
	pDc->MoveTo(pt);
	pt.x = rtDown.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = rtDown.left + nToLeft;
	pt.y = nBaseLine;
	pDc->MoveTo(pt);
	pt.x = rtDown.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 2);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 2);
	pDc->Polygon(ptArr, 3);

	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();

	//画刻度
	//一平所占的长度（米）
//  	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
//  	dLen = (Pile_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(Ham_Info.fPileLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画波形
	double dLen = GetYLen(dMax, Pile_Info);
	//绘制曲线
	dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	dXSite = nToLeft;
	dYSite = 0.0;

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
// 	double dPileLen = 0; //移动桩长
// 	CSize szText = 0;
// 	//鼠标移动
// 	if (0 == MoveState)
// 	{
// 		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= rtDown.left + nToLeft + nH_Wid)
// 		{
// 			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
// 			OldPen = pDc->SelectObject(&pen);
// 
// 			pDc->MoveTo(m_ptMouse.x, rtDown.bottom - 2 * nToTop);
// 			pDc->LineTo(m_ptMouse.x, rtDown.top + nToTop);
// 
// 			int nT1T2Gap = m_nT_PosX[2] - m_nT_PosX[1];
// 			if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
// 			{
// 				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
// 					m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen
// 					- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
// 					+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
// 			}
// 			else
// 			{
// // 				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
// // 					m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen) / nT1T2Gap;
// 
// //				dPileLen = (double(m_ptMouse.x - rtDrawWave.left + 1) / dXGap - Ham_Info.sPileTopPos + nHPos) * dGap;
// 
// 				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
// 					m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen
// 					- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
// 					+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
// 			}
// 
// 			if (dPileLen < 0)
// 			{
// 				dPileLen = 0;
// 			}
// 			strText.Format(L"%.02fm", dPileLen);
// 			szText = pDc->GetTextExtent(strText);
// 			pDc->SetTextColor(RGB(255, 0, 0));
// 			int nToTopHight = 2;	 //字体距离顶部的倍数
// 			if (m_ptMouse.x + 10 > rtDown.right - szText.cx)
// 			{
// 				pDc->TextOutW(m_ptMouse.x - szText.cx + 5, rtDown.top + nToTopHight * szText.cy / 3, strText);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(m_ptMouse.x + 5, rtDown.top + nToTopHight * szText.cy / 3, strText);
// 			}
// 			pDc->SetTextColor(RGB(0, 0, 0));
// 			pDc->SelectObject(OldPen);
// 			pen.DeleteObject();
// 		}
// 	}
// 	pDc->SelectObject(OldFont);
// 	font.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画上面的柱体
	int nTopLine = rtUp.Height() / 7;					//最上方线的间距
	int nGapLine = nTopLine / 3;						//条线的间距

	//A1的实际高度
	float fA1 = float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * Pile_Info.fSensorH[0];
	float fA2 = float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * Pile_Info.fSensorH[1];

	int nA1 = int(fA1);
	int nA2 = int(fA2);
	//画柱体 桩 
	int nPileW = 20;		//桩宽度
	pDc->FillSolidRect(CRect(2, nTopLine, nPileW + 2, rtUp.Height()), RGB(128, 138, 135));
	nPileW += 2;
	//画四条线
	pDc->MoveTo(nPileW, nTopLine);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine);

	pDc->MoveTo(nPileW, nTopLine + nA1);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine + nA1);

	pDc->MoveTo(nPileW, nTopLine + nA2);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine + nA2);

	pDc->MoveTo(nPileW, rtUp.Height());
	pDc->LineTo(nH_Wid + nToLeft, rtUp.Height());


	//画两个黑块
	int nBlock = 4;		//黑块的宽度
	pDc->FillSolidRect(CRect(nPileW, nTopLine + nA1 - nBlock, nPileW + nBlock, nTopLine + nA1 + nBlock), RGB(0, 0, 0));
	pDc->FillSolidRect(CRect(nPileW, nTopLine + nA2 - nBlock, nPileW + nBlock, nTopLine + nA2 + nBlock), RGB(0, 0, 0));
	//写 A1 A2
	strText = L"A1";

	szFont = pDc->GetTextExtent(strText);
	CRect rtWord = 0;		//文字区域
	rtWord.left = nPileW + nBlock;
	rtWord.top = nTopLine + nA1;
	rtWord.right = rtWord.left + szFont.cx + 2;
	rtWord.bottom = rtWord.top + szFont.cy;
	pDc->DrawText(strText, rtWord, DT_CENTER);
	strText = L"A2";
	rtWord.top = nTopLine + nA2;
	rtWord.bottom = rtWord.top + szFont.cy;
	pDc->DrawText(strText, rtWord, DT_CENTER);

	//写间距差
	strText.Format(L"%.02fm", Pile_Info.fSensorH[1] - Pile_Info.fSensorH[0]);
	szFont = pDc->GetTextExtent(strText);
	rtWord.top = nTopLine + nA1;
	rtWord.left = rtWord.right;
	rtWord.right = rtWord.left + szFont.cx + 2;
	rtWord.bottom = nTopLine + nA2;
	pDc->DrawText(strText, rtWord, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	pDc->SelectObject(OldFont);
	font.DeleteObject();

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画t1 - t4 位置
	float fTPos1 = 0, fTPos2 = 0, fTPos3 = 0, fTPos4 = 0;
	float fPreReq = float((1 / (g_nFrq[nFrq] * 1.0)) * 1000);
	//4个T的频率占比
	fTPos1 = Ham_Info.WA_Info[0].ft[0] / fPreReq;
	fTPos4 = Ham_Info.WA_Info[0].ft[1] / fPreReq;
	fTPos2 = Ham_Info.WA_Info[1].ft[0] / fPreReq;
	fTPos3 = Ham_Info.WA_Info[1].ft[1] / fPreReq;

	if (fTPos1 >= fTPos2)
	{
		//		fTPos1 = fTPos2 - 1;
		fTPos2 = fTPos1 + 1;
	}

	if (fTPos4 <= fTPos3)
	{
		fTPos4 = fTPos3 + 1;
	}
	//画竖线
	int nLineTop = 0;
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	int nTPos1 = 0, nTPos2 = 0, nTPos3 = 0, nTPos4 = 0;
	nTPos1 = int((fTPos1 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos1 = m_nT_PosX[0];
	strText = L"t1";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos1 - szFont.cx / 2, rtUp.top, strText);
	nLineTop = rtUp.top + szFont.cy + 2;

	pDc->MoveTo(nTPos1, nLineTop);
	pDc->LineTo(nTPos1, nTopLine + nA1);

	nTPos4 = int((fTPos4 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos4 = m_nT_PosX[3];
	strText = L"t4";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos4 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos4, nLineTop);
	pDc->LineTo(nTPos4, nTopLine + nA1);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	nTPos2 = int((fTPos2 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos2 = m_nT_PosX[1];

	strText = L"t2";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos2 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos2, nLineTop);
	pDc->LineTo(nTPos2, nTopLine + nA2);

	nTPos3 = int((fTPos3 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos3 = m_nT_PosX[2];
	strText = L"t3";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos3 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos3, nLineTop);
	pDc->LineTo(nTPos3, nTopLine + nA2);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画箭头
	//t1 -> t2
	DrawArrLine(pDc, nTPos1, nTopLine + nA1, nTPos2, nTopLine + nA2, PS_SOLID);
	//t2 -> 桩底
	DrawArrLine(pDc, nTPos2, nTopLine + nA2, (nTPos2 + nTPos3) / 2, rtUp.bottom, PS_SOLID);
	//桩底 -> t3
	DrawArrLine(pDc, (nTPos2 + nTPos3) / 2, rtUp.bottom, nTPos3, nTopLine + nA2, PS_SOLID);
	//桩底 -> t3
	DrawArrLine(pDc, nTPos3, nTopLine + nA2, nTPos4, nTopLine + nA1, PS_SOLID);

	//画虚线
	pen.CreatePen(PS_DASH, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	pDc->MoveTo((nTPos2 + nTPos3) / 2, nTopLine);
	pDc->LineTo((nTPos2 + nTPos3) / 2, rtUp.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画缺陷线
	if (!vecDefectPos1.empty())
	{
		int nA = 0;
		int nMiddlePos = 0; //中间位置长度
		for (int k = 0; k < (int)vecDefectPos1.size(); ++k)
		{
			nA = int(float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * vecDefectPos1[k].fLen);
			nMiddlePos = (vecDefectPos1[k].nPos + m_nT_PosX[0]) / 2;
			//画虚线
			pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(rtUp.left + 2, nTopLine + nA);
			pDc->LineTo(nMiddlePos, nTopLine + nA);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();

			DrawArrLine(pDc, nMiddlePos, nTopLine + nA, vecDefectPos1[k].nPos, nTopLine + nA1, PS_SOLID, g_SysSet.Cuver1clr);
		}
	}

	if (!vecDefectPos2.empty())
	{
		int nA = 0;
		int nMiddlePos = 0; //中间位置长度
		for (int k = 0; k < (int)vecDefectPos2.size(); ++k)
		{
			nA = int(float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * vecDefectPos2[k].fLen);
			nMiddlePos = (vecDefectPos2[k].nPos + m_nT_PosX[0]) / 2;
			//画虚线
			pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(rtUp.left + 2, nTopLine + nA);
			pDc->LineTo(nMiddlePos, nTopLine + nA);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();

			DrawArrLine(pDc, nMiddlePos, nTopLine + nA, vecDefectPos2[k].nPos, nTopLine + nA1, PS_SOLID, g_SysSet.Cuver2clr);
		}
	}

	double dPileLen = 0; //移动桩长
	CSize szText = 0;
	//鼠标移动
	if (0 == MoveState)
	{
		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= rtDown.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, rtDown.bottom - 2 * nToTop);
			pDc->LineTo(m_ptMouse.x, rtDown.top + nToTop);

			int nT1T2Gap = m_nT_PosX[2] - m_nT_PosX[1];
			if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
			{
				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
					m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen
					- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
					+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
			}
			else
			{
// 				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
// 					m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen) / nT1T2Gap;

				//				dPileLen = (double(m_ptMouse.x - rtDrawWave.left + 1) / dXGap - Ham_Info.sPileTopPos + nHPos) * dGap;

				dPileLen = float(m_ptMouse.x - m_nT_PosX[1])*(
					m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen
					- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
					+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
			}

			if (dPileLen < 0)
			{
				dPileLen = 0;
			}
			strText.Format(L"%.02fm", dPileLen);
			szText = pDc->GetTextExtent(strText);
			pDc->SetTextColor(RGB(255, 0, 0));
			int nToTopHight = 2;	 //字体距离顶部的倍数
			if (m_ptMouse.x + 10 > rtDown.right - szText.cx)
			{
				pDc->TextOutW(m_ptMouse.x - szText.cx + 5, rtDown.top + nToTopHight * szText.cy / 3, strText);
			}
			else
			{
				pDc->TextOutW(m_ptMouse.x + 5, rtDown.top + nToTopHight * szText.cy / 3, strText);
			}
			pDc->SetTextColor(RGB(0, 0, 0));
			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	pDc->SelectObject(OldFont);
	font.DeleteObject();
}

void CDrawWave::DrawNormalDownWave_1(CDC *pDc, DT56_PILE_INFO &Pile_Info, DT56_HAM_INFO &Ham_Info, int nPileNo, int nHamNo, int MoveState)
{
// 	DrawNormalDownWave_1(pDc, Pile_Info, Ham_Info, nPileNo, nHamNo, MoveState);
// 	return;
	/*
	WSDATA DataBuf1 = { 0 };
	WSDATA DataBuf2 = { 0 };
	//获取数据
	GetNormalDataBuf(DataBuf1, nPileNo, nHamNo, 0);
	GetNormalDataBuf(DataBuf2, nPileNo, nHamNo, 1);

	CFont font, *OldFont = NULL;
	SetWindowFont(font);
	OldFont = pDc->SelectObject(&font);

	int nHPos = 0; //一个水平值
	
	CRect rtUp = m_rtWave;			//波形上方区域
	rtUp.bottom = m_rtWave.Height() * 2 / 3;
	CRect rtDown = m_rtWave;		//下方波形区域
	rtDown.top = rtUp.bottom;

	CString strText(L"");
	int nFrq = Pile_Info.sCaiYangFreq;		//采样频率
	CPen pen, *OldPen = NULL;				//定义画笔

	int nToLeft = rtDown.Width() / 25;	//开始画位置距离左侧边框距离 
	int nToTop = rtDown.Height() / 25;		//距离底部位置 也是距离顶部位置 
	int nH_Wid = rtDown.Width() - nToLeft - nToLeft * 3;  //横坐标长度 右侧还有一些数值信息 留空白
	//坐标系的高度要比波形纵坐标高度 要多6个nToTop; (桩占2个 桩距离坐标系2个 距离上方波形2个)
	int nV_Hig = rtDown.Height() - 2 * nToTop;	//画坐标系的时候 坐标高度
	int nPileH = 3 * nToTop;					//桩的高度（宽度）
	int nWaveV_Hig = rtDown.Height() - nPileH - 6 * nToTop;	//波形纵坐标长度 实际的坐标高度
	int nBaseLine =  rtDown.top + 2 * nToTop + nWaveV_Hig / 2;		//基准线位置

	//为了将波形 都能放进区域内 获取所有波形做大的波形值
//	double dMax = GetWaveMaxValue(Ham_Info);
	double dMax = m_pData->GetUpWaveMaxValue(Pile_Info.sDataCnt);
	//Y轴两点间距
	double dYGap = 1.0;
	if (dMax > nWaveV_Hig * 1.0 / 2)
	{
		dYGap = dMax / (nWaveV_Hig * 1.0 / 2);
	}
	//X轴两点间距
	if (Ham_Info.sHZoom + Ham_Info.nMove_XZoom > Pile_Info.sDataCnt)
	{
		Ham_Info.nMove_XZoom = Pile_Info.sDataCnt - Ham_Info.sHZoom;
	}
	if (Ham_Info.nMove_XZoom < XZOOM_MIN)
	{
		Ham_Info.nMove_XZoom = XZOOM_MIN;
	}
	double dXGap = (double)nH_Wid / ((Ham_Info.sHZoom + Ham_Info.nMove_XZoom + Ham_Info.nMove_XZoom) * 1.0);


	int nPileTop = 0;			//桩顶位置
	int nPileBottom = 0;		//桩底位置
	//桩顶位置判断
	if (0 == Ham_Info.sPileTopPos)
	{
		nPileTop = Ham_Info.sPileTopPos = 200;
	}
	else
	{
		nPileTop = Ham_Info.sPileTopPos;
	}
	//桩底 位置计算
	nPileBottom = (int)(nPileTop + (2.0 * Ham_Info.fPileLen * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
	m_nPilePos = nPileTop;
	m_nPileBottom = nPileBottom;

	nHPos = int((Ham_Info.sPileTopPos * dXGap - (nH_Wid) / 8) / dXGap);
// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	int nDataCnts = Pile_Info.sDataCnt;  //采样点数

	//对桩顶和桩底位置进行判断
	if (nPileTop >= nDataCnts)
	{
		nPileTop = nDataCnts - 2;
		nPileBottom = nDataCnts - 1;
	}
	else if (nPileBottom >= nDataCnts)
	{
		nPileBottom = nDataCnts - 1;
	}
	else{}

	//字体大小
	CSize szFont = pDc->GetTextExtent(L"轻微");
	pDc->SetBkMode(TRANSPARENT);

	CRect rtPile; //获取桩区域
	rtPile.left = int(nToLeft + (nPileTop - nHPos) * dXGap);
	rtPile.top = rtDown.bottom - 3 * nToTop - nPileH;
	rtPile.right = int(nToLeft + (nPileBottom - nHPos) * dXGap);
	rtPile.bottom = rtDown.bottom - 3 * nToTop;
	if (rtPile.right > nH_Wid + nToLeft)
	{
		rtPile.right = nH_Wid + nToLeft;
	}
// 	//根据4个T时间来计算桩
// 	Pile_Info.fPrePileLen = m_nT_PosX[3] - m_nT_PosX[0];
	rtPile.left = m_nT_PosX[0];
	rtPile.right = m_nT_PosX[3];
	
	m_rtPile = rtPile;


	//画桩
	CString strStrings(L"");
//	pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	if (MoveState == 3)
	{
		//移动桩
		pDc->FillSolidRect(rtPile, RGB(128, 0, 64));
		strStrings = g_LoadString(L"DW_29");
		strText.Format(L"%.02fm", Ham_Info.fPileLen);
		strText = strStrings + strText;
//		strText.Format(L"桩长=%.02fm", Ham_Info.fPileLen);
		szFont = pDc->GetTextExtent(strText);
		CRect rtTextPile = rtPile;
		rtTextPile.left = rtPile.right + 5;
		rtTextPile.right = rtTextPile.left + szFont.cx + 2;
		pDc->SetTextColor(RGB(128, 0, 64));
		pDc->DrawText(strText, rtTextPile, DT_CENTER | DT_NOCLIP);
		pDc->SetTextColor(RGB(0, 0, 0));
	}
	else{
		pDc->FillSolidRect(rtPile, RGB(128, 138, 135));
	}

	//保存桩顶和桩底位置
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;
	m_nSpeedPosUp = m_rtWave.top + nToTop;
	m_nSpeedPosDown = rtPile.top - 1;
	//桩位置上下限
	m_nPilePosUp = rtPile.top;
	m_nPilePosDown = rtPile.bottom;

	CRect rtPileDefect = rtPile;
	CRect rtPi = rtPile;
	//桩底类型
	if (Ham_Info.chPileBottomType == 1) //尖底
	{
		rtPi.left = rtPile.right - 13;
		pDc->FillSolidRect(rtPi, RGB(255, 255, 255));
		CBrush brush, *pOldBrush = NULL;
		brush.CreateSolidBrush(RGB(128, 138, 135));
		pOldBrush = pDc->SelectObject(&brush);
		pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
		OldPen = pDc->SelectObject(&pen);

		CPoint ptP[3];
		ptP[0] = CPoint(rtPi.left, rtPi.top);
		ptP[1] = CPoint(rtPile.right, rtPile.top + rtPile.Height() / 2);
		ptP[2] = CPoint(rtPi.left, rtPi.bottom);
		pDc->Polygon(ptP, 3);

		pDc->SelectObject(pOldBrush);
		brush.DeleteObject();
		pDc->SelectObject(OldPen);
		pen.DeleteObject();
	}
	else if (Ham_Info.chPileBottomType == 2) //扩底
	{
		rtPi.left = rtPile.right - 10;
		rtPi.top = rtPile.top - 5;
		rtPi.bottom = rtPile.bottom + 5;
		pDc->FillSolidRect(rtPi, RGB(128, 138, 135));
	}
	double dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	//写上行波文字
	strText = g_LoadString(L"MB_106");
	szFont = pDc->GetTextExtent(strText);
	CRect rtWaveUpText;
	rtWaveUpText.top = rtDown.top + 2;
	rtWaveUpText.left = rtDown.left + 2;
	rtWaveUpText.right = rtWaveUpText.left + szFont.cx + 3;
	rtWaveUpText.bottom = rtWaveUpText.top + szFont.cy + 3;
	CBrush brush, *pOldBrush = NULL;
	brush.CreateSolidBrush(RGB(180, 0, 0));
	pOldBrush = pDc->SelectObject(&brush);
	pDc->FillRect(rtWaveUpText, &brush);
	pDc->DrawText(strText, rtWaveUpText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
//	pDc->TextOutW(rtWaveUpText.left, rtWaveUpText.top, strText);
	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();


	//画上行波形
	double dXSite = nToLeft;
	double dYSite = 0;
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	CPoint pt = 0;
//	m_nHPos = nHPos + Ham_Info.nMoveL_R[0];
	m_nHPos = nHPos;
// 	if (m_nHPos < 0)
// 	{
// 		m_nHPos = 0;
// 	}
	if (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL)
	{
		pt.x = (long)dXSite;
		if (nHPos < 0)
		{
			pt.x = (long)(dXSite + abs(nHPos) * dXGap);
		}
		pt.y = (long)nBaseLine - (int)(m_pData->m_UpWaveData[m_nHPos] / dYGap * dHfe);
		pDc->MoveTo(pt);
		for (int i = m_nHPos; i < Pile_Info.sDataCnt; ++i)
		{
			if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
			{
				break;
			}
			if (i < 0)
			{
				dYSite = nBaseLine;
			}
			else
			{
				dYSite = nBaseLine - (int)(g_nWaveResever * m_pData->m_UpWaveData[i] / dYGap * dHfe);
			}
			
			pt.x = (long)dXSite;
			pt.y = (long)dYSite;
			pDc->LineTo(pt);
			dXSite += dXGap;
		}
	}
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	//保存缺陷位置和长度
	vector<DEFECT_POS> vecDefectPos1; 
	vector<DEFECT_POS> vecDefectPos2;
	//画桩缺陷
	int nT2T3Gap = m_nT_PosX[2] - m_nT_PosX[1];  //t2 t3间距
	CRect rtDef = rtPileDefect;
	CPoint ptDefect;
	if (Ham_Info.WA_Info[0].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_1 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[0].chDefectCnt; i++)
		{
			//判断缺陷是否出界
			if (Ham_Info.WA_Info[0].fDefectPos[i] <= Pile_Info.fSensorH[1] || Ham_Info.WA_Info[0].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[0].fDefectPos[j] = Ham_Info.WA_Info[0].fDefectPos[j + 1];
					Ham_Info.WA_Info[0].chDefectLevel[j] = Ham_Info.WA_Info[0].chDefectLevel[j + 1];
					Ham_Info.WA_Info[0].chDefectType[j] = Ham_Info.WA_Info[0].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[0].chDefectCnt--;
				i--;
				continue;
			}
			
// 			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[0].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));	
// 			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
			ptDefect.x = long((Ham_Info.WA_Info[0].fDefectPos[i] - Pile_Info.fSensorH[1]) * (float)nT2T3Gap / (Ham_Info.fPileLen - Pile_Info.fSensorH[1]));
			ptDefect.x += m_nT_PosX[1];

			DEFECT_POS defect_pos;
			defect_pos.nPos = ptDefect.x;
			defect_pos.fLen = Ham_Info.WA_Info[0].fDefectPos[i];
			vecDefectPos1.push_back(defect_pos);
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[0].chDefectType[i]);
		}
	}
	//波形2缺陷
	if (Ham_Info.WA_Info[1].chDefectCnt > 0 && (g_WaveShow == WAVE_SHOW_2 || g_WaveShow == WAVE_SHOW_ALL))
	{
		for (int i = 0; i < Ham_Info.WA_Info[1].chDefectCnt; i++)
		{//判断缺陷是否出界
			if (Ham_Info.WA_Info[1].fDefectPos[i] <= Pile_Info.fSensorH[1] || Ham_Info.WA_Info[1].fDefectPos[i] > Ham_Info.fPileLen)
			{
				for (int j = i; j < Ham_Info.WA_Info[0].chDefectCnt - 1; ++j)
				{
					Ham_Info.WA_Info[1].fDefectPos[j] = Ham_Info.WA_Info[1].fDefectPos[j + 1];
					Ham_Info.WA_Info[1].chDefectLevel[j] = Ham_Info.WA_Info[1].chDefectLevel[j + 1];
					Ham_Info.WA_Info[1].chDefectType[j] = Ham_Info.WA_Info[1].chDefectType[j + 1];
				}
				Ham_Info.WA_Info[1].chDefectCnt--;
				i--;
				continue;
			}
// 			double dPos = double(nPileTop + (2.0 * Ham_Info.WA_Info[1].fDefectPos[i] * g_nFrq[nFrq]) / (Ham_Info.nWaveSpeed * 1.0));
// 			ptDefect.x = int(nToLeft + (dPos - nHPos) * dXGap);
			ptDefect.x = long((Ham_Info.WA_Info[1].fDefectPos[i] - Pile_Info.fSensorH[1]) * (float)nT2T3Gap / (Ham_Info.fPileLen - Pile_Info.fSensorH[1]));
			ptDefect.x += m_nT_PosX[1];

			DEFECT_POS defect_pos;
			defect_pos.nPos = ptDefect.x;
			defect_pos.fLen = Ham_Info.WA_Info[1].fDefectPos[i];
			vecDefectPos2.push_back(defect_pos);
			//桩缺陷
			rtDef.left = ptDefect.x - m_nDefectWD;
			rtDef.right = ptDefect.x + m_nDefectWD;
			SetDefect(pDc, rtDef, Ham_Info.WA_Info[1].chDefectType[i]);
		}
	}
	

	//PS_DOT点线
// 	pen.CreatePen(PS_DOT, 1, RGB(128, 138, 135));
// 	OldPen = pDc->SelectObject(&pen);
// 	//画桩头
// 	pt.x = rtPile.left;
// 	pt.y = rtPile.top;
// 	pDc->MoveTo(pt);
// 	pt.y = nBaseLine - int(g_nWaveResever * DataBuf1[nPileTop] / dYGap * dHfe);
// 	pDc->LineTo(pt);
// 	
// 	//画桩尾
// 	pt.x = rtPile.right - 1;
// 	pt.y = rtPile.top;
// 	pDc->MoveTo(pt);
// 	pt.y = nBaseLine - int(g_nWaveResever * DataBuf1[nPileBottom] / dYGap * dHfe);
// 	pDc->LineTo(pt);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画坐标系
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画竖坐标线
	pt.x = rtDown.left + nToLeft;
	pt.y = rtDown.bottom;
	pDc->MoveTo(pt);
	pt.y = rtDown.top + 15;
	pDc->LineTo(pt);
	//画箭头
	CPoint ptArr[3];
	ptArr[0] = CPoint(pt.x, pt.y - 10);
	ptArr[1] = CPoint(pt.x - 2, pt.y);
	ptArr[2] = CPoint(pt.x + 2, pt.y);
	pDc->Polygon(ptArr, 3);

	//横坐标
	pt.x = rtDown.left + nToLeft;
	pt.y = rtDown.bottom - nToTop;
	pDc->MoveTo(pt);
	pt.x = rtDown.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_DOT, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画基准线
	pt.x = rtDown.left + nToLeft;
	pt.y = nBaseLine;
	pDc->MoveTo(pt);
	pt.x = rtDown.left + nToLeft + nH_Wid;
	pDc->LineTo(pt);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画箭头
	ptArr[0] = pt;
	ptArr[1] = CPoint(pt.x - 10, pt.y - 2);
	ptArr[2] = CPoint(pt.x - 10, pt.y + 2);
	pDc->Polygon(ptArr, 3);

	//画刻度
	//一平所占的长度（米）
	double dLen = (Ham_Info.sHZoom - nPileTop + nHPos) * Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]);
	int nBigMark = GetXKeDu(dLen);		//大标记位置
	int nSamllMark = 0;		 //小的标记刻度位置
// 	if (dLen > 5.0)
// 	{
// 		nBigMark = 20;
// 	}
// 	else if (dLen > 20.0)
// 	{
// 		nBigMark = 50;
// 	}
// 	else
// 	{
// 		nBigMark = 100;
// 	}

	nSamllMark = nBigMark / 5;  //5个小标记
	CRect rtNum = 0;			//用于写字时定义字的区域
	int nStepStart = 0;			//已经走的步长
	double dMarkLen = 0.0;
	int  nSite = 0;				//当前位置
	int	 nSiteBack = -1;			//记录上次的值
	double dGap = (double)Ham_Info.nWaveSpeed / (2 * g_nFrq[nFrq]); //单位长度
	m_dGap = dGap;
// 	for (int i = 0; i < nDataCnts; ++i)
// 	{
// 		dMarkLen = double(i * dGap);
// 		nSite = int(dMarkLen * 10);
// 		nStepStart = int((i + nPileTop - nHPos) * dXGap) + rtDown.left + nToLeft;
// 		//如果出了坐标轴就不画了
// 		if (nStepStart > rtDown.left + nToLeft + nH_Wid)
// 		{
// 			break;
// 		}
// 		if (nSite == nSiteBack)
// 		{
// 			continue;
// 		}
// 		nSiteBack = nSite;
// 		if (0 == nSite % nBigMark) //画长刻度线 并带刻度
// 		{
// 			pDc->MoveTo(nStepStart, rtDown.bottom - nToTop);
// 			pDc->LineTo(nStepStart, rtDown.bottom - nToTop - 5);
// 			rtNum.SetRect(nStepStart - 10, rtDown.bottom - nToTop - 20, nStepStart + 10, rtDown.bottom - nToTop);
// 			if (0 == nSite)
// 			{
// 				strText = L"0.0";
// 			}
// 			else
// 			{
// 				strText.Format(L"%.01f", (1 / (g_nFrq[nFrq] * 1.0)) * 1000 * i);
// 			}
// 			pDc->DrawText(strText, rtNum, DT_CENTER | DT_NOCLIP);
// 		}
// 		else if (0 == nSite % nSamllMark)//画短刻度线 不画刻度
// 		{
// 			pDc->MoveTo(nStepStart, rtDown.bottom - nToTop);
// 			pDc->LineTo(nStepStart, rtDown.bottom - nToTop - 3);
// 		}
// 	}
	//横坐标单位 时间
// 	strText = L"ms";
// 	pDc->TextOutW(rtDown.left + nToLeft + nH_Wid + 3, rtDown.bottom - nToTop - 10, strText);
	//纵坐标单位 速度或者加速度
// 	strText = L"m/s";
// 	pt = CPoint(rtDown.left + nToLeft + 10, rtDown.top + nToTop);
// 	pDc->TextOutW(pt.x, pt.y, strText);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	//画波形
	dLen = GetYLen(dMax, Pile_Info);
// 	if (g_WaveShowMode == WAVE_SHOW_V)		//速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8) / (32768 * 2 * (g_nFrq[Pile_Info.sCaiYangFreq] / 1000) * 1) * 3;
// 	}
// 	else			//加速度
// 	{
// 		dLen = (dMax * 2.5 * 9.8 * 1000) / (32768 * 2 * 100) * 3;
// 	}

// 	nSite = (int)(dMax / dYGap);  //像素点数
// 	if (0 == nSite)
// 	{
// 		nSite = int(0.3617 * nWaveV_Hig);
// 	}
// 	double dKeDu = (dLen * Pile_Info.fSensorS[0]) / 100.0;
// 	double dKeDu1 = (dLen * Pile_Info.fSensorS[1]) / 100.0;
// 
// 	dKeDu = dKeDu > dKeDu1 ? dKeDu : dKeDu1;

// 	pt.x = rtDown.left + nToLeft;
// 	pt.y = nBaseLine - nSite;
// 	pDc->MoveTo(pt);
// 	pDc->LineTo(pt.x - 5, pt.y);
// 
// 	strText.Format(L"%.02f", dKeDu);
// 	CSize szText = pDc->GetTextExtent(strText);
// 	CRect rtText = 0;
// 	rtText.right = pt.x - 10;
// 	rtText.left = rtText.right - szText.cx;
// 	rtText.top = pt.y - szText.cy / 2;
// 	rtText.bottom = rtText.top + szText.cy;
// 	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
// 	strText = L"(max)";
// 	rtText.top += (szText.cy);
// 	rtText.bottom = rtText.top + szText.cy;
// 	pDc->DrawText(strText, rtText, DT_CENTER | DT_NOCLIP);
	//绘制曲线
	dHfe = pow(2, (Ham_Info.sVZoom - 49) / 15.0);
	dXSite = nToLeft;
	dYSite = 0.0;

// 	if (nHPos < 0)
// 	{
// 		nHPos = 0;
// 	}
	//画波形1
// 	pt.x = (long)dXSite;
// 	pt.y = (long)nBaseLine - (int)(g_nWaveResever * DataBuf1[nHPos] / dYGap * dHfe);
// 	pDc->MoveTo(pt);
// 	for (int i = nHPos; i < Pile_Info.sDataCnt; ++i)
// 	{
// 		if (dXSite >= m_rtWave.left + nToLeft + nH_Wid)
// 		{
// 			break;
// 		}
// 		dYSite = nBaseLine - (int)(g_nWaveResever * DataBuf1[i] / dYGap * dHfe);
// 		pt.x = (long)dXSite;
// 		pt.y = (long)dYSite;
// 		pDc->LineTo(pt);
// 		dXSite += dXGap;
// 	}
// 	pen.CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
// 	OldPen = pDc->SelectObject(&pen);

	pDc->SelectObject(OldPen);
	pen.DeleteObject();
	double dPileLen = 0; //移动桩长
	CSize szText = 0;
	//鼠标移动
	if (0 == MoveState)
	{
		if (m_ptMouse.x > nToLeft && m_ptMouse.x <= rtDown.left + nToLeft + nH_Wid)
		{
			pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 0));
			OldPen = pDc->SelectObject(&pen);

			pDc->MoveTo(m_ptMouse.x, rtDown.bottom - 2 * nToTop);
			pDc->LineTo(m_ptMouse.x, rtDown.top + nToTop);

// 			//移动桩长
// 			dPileLen = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * dGap;
// 			if (dPileLen < 0)
// 			{
// 				dPileLen = 0;
// 			}
// 			strText.Format(L"%.02fm", dPileLen);
// 			szText = pDc->GetTextExtent(strText);
// 			pDc->SetTextColor(RGB(255, 0, 0));
// 			int nToTopHight = 3;	 //字体距离顶部的倍数
// 			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(m_ptMouse.x - szText.cx, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szText.cy, strText);
// 			}
// 			//移动时间
// 			double dTime = (double(m_ptMouse.x - nToLeft) / dXGap - nPileTop + nHPos) * (1 / (g_nFrq[nFrq] * 1.0)) * 1000;
// 			strText.Format(L"%.02fms", dTime);
// 			szFont = pDc->GetTextExtent(strText);
// 			pDc->SetTextColor(RGB(0, 0, 0));
// 			nToTopHight++;
// 			if (m_ptMouse.x + 10 > m_rtWave.left + nToLeft + nH_Wid - szText.cx)
// 			{
// 				pDc->TextOutW(m_ptMouse.x - szFont.cx, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}
// 			else
// 			{
// 				pDc->TextOutW(m_ptMouse.x, m_rtWave.top + nToTop + nToTopHight * szFont.cy, strText);
// 			}

			pDc->SelectObject(OldPen);
			pen.DeleteObject();
		}
	}
	pDc->SelectObject(OldFont);
	font.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);
	//画上面的柱体
	int nTopLine = rtUp.Height() / 7;					//最上方线的间距
	int nGapLine = nTopLine / 3;						//条线的间距

	//A1的实际高度
	float fA1 = float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * Pile_Info.fSensorH[0];
	float fA2 = float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * Pile_Info.fSensorH[1];

	int nA1 = int(fA1);
	int nA2 = int(fA2);
	//画柱体 桩 
	int nPileW = 20;		//桩宽度
	pDc->FillSolidRect(CRect(2, nTopLine, nPileW + 2, rtUp.Height()), RGB(128, 138, 135));
	nPileW += 2;
	//画四条线
	pDc->MoveTo(nPileW, nTopLine);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine);

	pDc->MoveTo(nPileW, nTopLine + nA1);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine + nA1);

	pDc->MoveTo(nPileW, nTopLine + nA2);
	pDc->LineTo(nH_Wid + nToLeft, nTopLine + nA2);

	pDc->MoveTo(nPileW, rtUp.Height());
	pDc->LineTo(nH_Wid + nToLeft, rtUp.Height());


	//画两个黑块
	int nBlock = 4;		//黑块的宽度
	pDc->FillSolidRect(CRect(nPileW, nTopLine + nA1 - nBlock, nPileW + nBlock, nTopLine + nA1 + nBlock), RGB(0, 0, 0));
	pDc->FillSolidRect(CRect(nPileW, nTopLine + nA2 - nBlock, nPileW + nBlock, nTopLine + nA2 + nBlock), RGB(0, 0, 0));
	//写 A1 A2
	strText = L"A1";

	szFont = pDc->GetTextExtent(strText);
	CRect rtWord = 0;		//文字区域
	rtWord.left = nPileW + nBlock;
	rtWord.top = nTopLine + nA1;
	rtWord.right = rtWord.left + szFont.cx + 2;
	rtWord.bottom = rtWord.top + szFont.cy;
	pDc->DrawText(strText, rtWord, DT_CENTER);
	strText = L"A2";
	rtWord.top = nTopLine + nA2;
	rtWord.bottom = rtWord.top + szFont.cy;
	pDc->DrawText(strText, rtWord, DT_CENTER);

	//写间距差
	strText.Format(L"%.02fm", Pile_Info.fSensorH[1] - Pile_Info.fSensorH[0]);
	szFont = pDc->GetTextExtent(strText);
	rtWord.top = nTopLine + nA1;
	rtWord.left = rtWord.right;
	rtWord.right = rtWord.left + szFont.cx + 2;
	rtWord.bottom = nTopLine + nA2;
	pDc->DrawText(strText, rtWord, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	pDc->SelectObject(OldFont);
	font.DeleteObject();

	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画t1 - t4 位置
	float fTPos1 = 0, fTPos2 = 0, fTPos3 = 0, fTPos4 = 0;
	float fPreReq = float((1 / (g_nFrq[nFrq] * 1.0)) * 1000);
	//4个T的频率占比
	fTPos1 = Ham_Info.WA_Info[0].ft[0] / fPreReq;
	fTPos4 = Ham_Info.WA_Info[0].ft[1] / fPreReq;
	fTPos2 = Ham_Info.WA_Info[1].ft[0] / fPreReq;
	fTPos3 = Ham_Info.WA_Info[1].ft[1] / fPreReq;

	if (fTPos1 >= fTPos2)
	{
//		fTPos1 = fTPos2 - 1;
		fTPos2 = fTPos1 + 1;
	}

	if (fTPos4 <= fTPos3)
	{
		fTPos4 = fTPos3 + 1;
	}
	//画竖线
	int nLineTop = 0;
	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver1clr);
	OldPen = pDc->SelectObject(&pen);
	int nTPos1 = 0, nTPos2 = 0, nTPos3 = 0, nTPos4 = 0;
	nTPos1 = int((fTPos1 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos1 = m_nT_PosX[0];
	strText = L"t1";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos1 - szFont.cx / 2, rtUp.top, strText);
	nLineTop = rtUp.top + szFont.cy + 2;

	pDc->MoveTo(nTPos1, nLineTop);
	pDc->LineTo(nTPos1, nTopLine + nA1);

	nTPos4 = int((fTPos4 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos4 = m_nT_PosX[3];
	strText = L"t4";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos4 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos4, nLineTop);
	pDc->LineTo(nTPos4, nTopLine + nA1);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	pen.CreatePen(PS_SOLID, 1, g_SysSet.Cuver2clr);
	OldPen = pDc->SelectObject(&pen);
	nTPos2 = int((fTPos2 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos2 = m_nT_PosX[1];

	strText = L"t2";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos2 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos2, nLineTop);
	pDc->LineTo(nTPos2, nTopLine + nA2);

	nTPos3 = int((fTPos3 + nPileTop - nHPos) * dXGap) + m_rtWave.left + nToLeft;
	nTPos3 = m_nT_PosX[2];
	strText = L"t3";
	szFont = pDc->GetTextExtent(strText);
	pDc->TextOutW(nTPos3 - szFont.cx / 2, rtUp.top, strText);

	pDc->MoveTo(nTPos3, nLineTop);
	pDc->LineTo(nTPos3, nTopLine + nA2);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画箭头
	//t1 -> t2
	DrawArrLine(pDc, nTPos1, nTopLine + nA1, nTPos2, nTopLine + nA2, PS_SOLID);
	//t2 -> 桩底
	DrawArrLine(pDc, nTPos2, nTopLine + nA2, (nTPos2 + nTPos3) / 2, rtUp.bottom, PS_SOLID);
	//桩底 -> t3
	DrawArrLine(pDc, (nTPos2 + nTPos3) / 2, rtUp.bottom, nTPos3, nTopLine + nA2, PS_SOLID);
	//桩底 -> t3
	DrawArrLine(pDc, nTPos3, nTopLine + nA2, nTPos4, nTopLine + nA1, PS_SOLID);

	//画虚线
	pen.CreatePen(PS_DASH, 1, RGB(0, 0, 0));
	OldPen = pDc->SelectObject(&pen);

	pDc->MoveTo((nTPos2 + nTPos3) / 2, nTopLine);
	pDc->LineTo((nTPos2 + nTPos3) / 2, rtUp.bottom);
	pDc->SelectObject(OldPen);
	pen.DeleteObject();

	//画缺陷线
	if (!vecDefectPos1.empty())
	{
		int nA = 0; 
		int nMiddlePos = 0; //中间位置长度
		for (int k = 0; k < (int)vecDefectPos1.size(); ++k)
		{
			nA = int(float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * vecDefectPos1[k].fLen);
			nMiddlePos = (vecDefectPos1[k].nPos + m_nT_PosX[0]) / 2;
			//画虚线
			pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver1clr);
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(rtUp.left+2, nTopLine + nA);
			pDc->LineTo(nMiddlePos, nTopLine + nA);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();

			DrawArrLine(pDc, nMiddlePos, nTopLine + nA, vecDefectPos1[k].nPos, nTopLine + nA1, PS_SOLID, g_SysSet.Cuver1clr);
		}
	}

	if (!vecDefectPos2.empty())
	{
		int nA = 0;
		int nMiddlePos = 0; //中间位置长度
		for (int k = 0; k < (int)vecDefectPos2.size(); ++k)
		{
			nA = int(float(rtUp.Height() - nTopLine) / Ham_Info.fPileLen * vecDefectPos2[k].fLen);
			nMiddlePos = (vecDefectPos2[k].nPos + m_nT_PosX[0]) / 2;
			//画虚线
			pen.CreatePen(PS_DASH, 1, g_SysSet.Cuver2clr);
			OldPen = pDc->SelectObject(&pen);
			pDc->MoveTo(rtUp.left+2, nTopLine + nA);
			pDc->LineTo(nMiddlePos, nTopLine + nA);
			pDc->SelectObject(OldPen);
			pen.DeleteObject();

			DrawArrLine(pDc, nMiddlePos, nTopLine + nA, vecDefectPos2[k].nPos, nTopLine + nA1, PS_SOLID, g_SysSet.Cuver2clr);
		}
	}
	*/
}


//画带箭头的直线后者虚线
void CDrawWave::DrawArrLine(CDC *pDc, int x1, int y1, int x2, int y2, int nPenStyle, COLORREF rgb)
{
	CPen pen, *pOldPen = NULL;
	pen.CreatePen(nPenStyle, 1, rgb);
	pOldPen = pDc->SelectObject(&pen);
	CBrush brush, *pOldBrush = NULL;
	brush.CreateSolidBrush(RGB(0, 0, 0));
	pOldBrush = pDc->SelectObject(&brush);


	pDc->MoveTo(x1, y1);
	pDc->LineTo(x2, y2);

	CPoint pt[3] = {0};
	pt[2].x = x2;
	pt[2].y = y2;
	CDrawWavecalcVertexes(x1, y1, x2, y2, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
	pDc->Polygon(pt, 3);
	pDc->SelectObject(pOldPen);
	pen.DeleteObject();
	pDc->SelectObject(pOldBrush);
	brush.DeleteObject();
}



void CDrawWave::CDrawWavecalcVertexes(double start_x, double start_y, double end_x, double end_y, long& x1, long& y1, long& x2, long& y2)
{
	double angle = atan2(end_y - start_y, end_x - start_x);
	int arrow_lenght_ = 10;
	double arrow_degrees_ = 0.40;
	x1 = long(end_x - arrow_lenght_ * cos(angle - arrow_degrees_));

	y1 = long(end_y - arrow_lenght_ * sin(angle - arrow_degrees_));

	x2 = long(end_x - arrow_lenght_ * cos(angle + arrow_degrees_));

	y2 = long(end_y - arrow_lenght_ * sin(angle + arrow_degrees_));
}


void CDrawWave::Rotate()
{
	//计算鼠标对于的点位置
	int nRotatePtCur = 0;
	if (g_WaveOperate == WAVE_OPERATE_1)
	{
		nRotatePtCur = int(double(m_ptMouse.x - m_nToLeft) / m_dXGap) + m_nHPos;
	}
	else if (g_WaveOperate == WAVE_OPERATE_2)
	{
		nRotatePtCur = int(double(m_ptMouse.x - m_nToLeft) / m_dXGap) + m_nHPos2;
	}
	
	double dOffset = 0;
	if (m_enWaveBack == Ave_Wave || m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		dOffset = 0 - m_pData->m_SpeedDataAvg[g_WaveOperate][m_pData->m_nSelPileNo][nRotatePtCur];
// 		m_pData->Rotate(m_pData->m_SpeedDataAvgScal[g_WaveOperate][m_pData->m_nSelPileNo],
// 			m_pData->m_SpeedDataAvg[g_WaveOperate][m_pData->m_nSelPileNo],
// 			m_pData->m_AcceDataAvg[g_WaveOperate][m_pData->m_nSelPileNo],
// 			m_nPtLast,
// 			nRotatePtCur,
// 			dOffset, 
// 			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).sPileTopPos, 
// 			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		m_pData->Rotate(m_pData->m_nSelPileNo,
			m_pData->m_nSelHamNo,
			m_nPtLast,
			nRotatePtCur,
			dOffset,
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).sPileTopPos,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);

	}
	else
	{
		dOffset = 0 - m_pData->m_SpeedData[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo][nRotatePtCur];
// 		m_pData->Rotate(m_pData->m_SpeedDataScal[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo],
// 			m_pData->m_SpeedData[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo],
// 			m_pData->m_AcceData[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo],
// 			m_nPtLast,
// 			nRotatePtCur,
// 			dOffset, 
// 			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).sPileTopPos, 
// 			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		m_pData->Rotate(m_pData->m_nSelPileNo,
			m_pData->m_nSelHamNo,
			m_nPtLast,
			nRotatePtCur,
			dOffset,
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).sPileTopPos,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);

	}
	m_nPtLast = nRotatePtCur;
}

void CDrawWave::RotateLocation(BOOL bUp)
{
	//计算鼠标对于的点位置
	int nBeginPos = 0;
	if (g_WaveOperate == WAVE_OPERATE_1)
	{
		nBeginPos = int(double(m_ptLocatLine.x - m_nToLeft) / m_dXGap) + m_nHPos;
	}
	else if (g_WaveOperate == WAVE_OPERATE_2)
	{
		nBeginPos = int(double(m_ptLocatLine.x - m_nToLeft) / m_dXGap) + m_nHPos2;
	}

	int nRotatePtCur = m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt;
	double dOffset = 0;
	int nMaxRotateOffset = 10;    //手动上下旋转最大偏移
 	if (m_enWaveBack == Ave_Wave || m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		dOffset = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).dWaveVMax[g_WaveOperate] / nMaxRotateOffset;
		if (!bUp)
		{
			dOffset *= -1;
		}
		m_pData->Rotate(m_pData->m_nSelPileNo,
			m_pData->m_nSelHamNo,
			nBeginPos,
			nRotatePtCur,
			dOffset,
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).sPileTopPos,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
	}
	else
	{
		dOffset = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).dWaveVMax[g_WaveOperate] / nMaxRotateOffset;
		if (!bUp)
		{
			dOffset *= -1;
		}

		m_pData->Rotate(m_pData->m_nSelPileNo,
			m_pData->m_nSelHamNo,
			nBeginPos,
			nRotatePtCur,
			dOffset,
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).sPileTopPos,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
	}
}

void CDrawWave::RotateSection(int nType)
{
	//计算鼠标对于的点位置
	int nStart = 0;
	int nEnd = 0;
	if (g_WaveOperate == WAVE_OPERATE_1)
	{
		nStart = int(double(m_PtSec[0].x - m_nToLeft) / m_dXGap) + m_nHPos;
		nEnd = int(double(m_PtSec[1].x - m_nToLeft) / m_dXGap) + m_nHPos;
	}
	else if (g_WaveOperate == WAVE_OPERATE_2)
	{
		nStart = int(double(m_PtSec[0].x - m_nToLeft) / m_dXGap) + m_nHPos2;
		nEnd = int(double(m_PtSec[1].x - m_nToLeft) / m_dXGap) + m_nHPos2;
	}
	double dOffset = 0;
	int nMaxRotateOffset = 100;    //手动上下旋转最大偏移
	if (m_enWaveBack == Ave_Wave || m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		if (0 == nType || 3 == nType)
		{
			m_pData->RotateSecZero(m_pData->m_nSelPileNo,
				m_pData->m_nSelHamNo,
				nStart,
				nEnd,
				nType,
				m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		}
		else if (1 == nType || 2 == nType)
		{
			dOffset = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).dWaveVMax[g_WaveOperate] / nMaxRotateOffset;
			if (nType == 2)
			{
				dOffset *= -1;
			}
			m_pData->RotateSec(m_pData->m_nSelPileNo,
				m_pData->m_nSelHamNo,
				nStart,
				nEnd,
				dOffset,
				m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		}
	}
	else
	{
		if (0 == nType || 3 == nType)
		{
			m_pData->RotateSecZero(m_pData->m_nSelPileNo,
				m_pData->m_nSelHamNo,
				nStart,
				nEnd,
				nType,
				m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		}
		else if (1 == nType || 2 == nType)
		{
			dOffset = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).dWaveVMax[g_WaveOperate] / nMaxRotateOffset;
			if (nType == 2)
			{
				dOffset *= -1;
			}
			m_pData->RotateSec(m_pData->m_nSelPileNo,
				m_pData->m_nSelHamNo,
				nStart,
				nEnd,
				dOffset,
				m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
		}
	}
}

//前清后清
void CDrawWave::WaveClear(WAVE_CLEAR Wave_Clear)
{
	if (Wave_Clear == WAVE_CLEAE_NO)
	{
		return;
	}
	//计算鼠标对于的点位置
	int nBeginPos = 0;
	if (g_WaveOperate == WAVE_OPERATE_1)
	{
		nBeginPos = int(double(m_ptMouse.x - m_nToLeft) / m_dXGap) + m_nHPos;
	}
	else if (g_WaveOperate == WAVE_OPERATE_2)
	{
		nBeginPos = int(double(m_ptMouse.x - m_nToLeft) / m_dXGap) + m_nHPos2;
	}

	if (m_enWaveBack == Ave_Wave || m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		m_pData->WaveClear(m_pData->m_SpeedDataAvgScal[g_WaveOperate][m_pData->m_nSelPileNo],
			m_pData->m_AcceDataAvg[g_WaveOperate][m_pData->m_nSelPileNo],
			nBeginPos,
			Wave_Clear,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
	}
	else
	{
		m_pData->WaveClear(m_pData->m_SpeedDataScal[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo],
			m_pData->m_AcceData[g_WaveOperate][m_pData->m_nSelPileNo][m_pData->m_nSelHamNo],
			nBeginPos,
			Wave_Clear,
			m_pData->m_vecPile.at(m_pData->m_nSelPileNo).sDataCnt);
	}
}

// 获取鼠标位置的点数
// int CDrawWave::GetMousePos(CPoint pt)
// {
// 	int nPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos;
// 	return nPos;
// }

//获取鼠标位置位置桩长
float CDrawWave::GetMousePileLen(CPoint pt)
{
	float fLen = float((double(pt.x - m_nToLeft) / m_dXGap - m_nPilePos + m_nHPos) * m_dGap);
	//TRACE(L"fLen = %f\r\n", fLen);
	if (fLen <= 0.1)
	{
		fLen = (float)0.10;
	}
	m_pData->SetPileLen(fLen, m_pData->m_nSelPileNo, m_pData->m_nSelHamNo);
// 	if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
// 	{
// 		m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).fPileLen = fLen;
// 	}
// 	else
// 	{
// 		m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).fPileLen = fLen;
// 	}
	return fLen;
}


//常规分析 移动时间标志线需改四个时间坐标 nMoveState = 5
void CDrawWave::GetTimeLine(CPoint pt, int nNo)
{
	float dLen = float(double(pt.x - m_nToLeft) / m_dXGap - m_nPilePos + m_nHPos);
	float fReq = dLen * m_fPreFreq;
	float fOtherReq = 0;
	float fOtherFreq = 0;
	float fCha = 0; //时间差
	//t1
	if (0 == nNo)
	{
		if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			fOtherReq = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[0]; //t2
			if (fReq > fOtherReq) //不能大于t2
			{
				fReq = fOtherReq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[0] = fReq;
			fCha = fOtherReq - fReq;
			//重新计算t4
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[1] = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1] + fCha;
		}
		else
		{
			fOtherReq = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[0];//t2
			if (fReq > fOtherReq)
			{
				fReq = fOtherReq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[0] = fReq;
			fCha = fOtherReq - fReq;
			//重新计算t4
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[1]
				= m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1] + fCha;
		}
	}
	else if (1 == nNo) //t2
	{
		if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			fOtherReq = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[0]; //t1
			fOtherFreq = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1]; //t3
			if (fReq > fOtherFreq) //不能大于t3
			{
				fReq = fOtherFreq;
			}
			if (fReq < fOtherReq) //不能小于t1
			{
				fReq = fOtherReq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			//赋值t2
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[0] = fReq;
			fCha = fReq - fOtherReq;
			//重新计算t4
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[1] = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1] + fCha;
		}
		else
		{
			fOtherReq = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[0];//t1
			fOtherFreq = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1];//t3
			if (fReq > fOtherFreq)//不能大于t3
			{
				fReq = fOtherFreq;
			}
			if (fReq < fOtherReq) //不能小于t1
			{
				fReq = fOtherReq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			//赋值t2
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[0] = fReq;
			fCha = fReq - fOtherReq;
			//重新计算t4
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[1]
				= m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1] + fCha;
		}
	}
	else if (2 == nNo) //t3
	{
		if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			fOtherReq = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1]; //t4
			fOtherFreq = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[0]; //t2
			float nFeq1 = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[0]; //t1
			if (fReq > fOtherReq) //不能大于t4
			{
				fReq = fOtherReq;
			}
			if (fReq < fOtherFreq) //不能小于t2
			{
				fReq = fOtherFreq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			//赋值t3
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1] = fReq;
			fCha = fOtherFreq - nFeq1;
			//重新计算t4
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[1] = 
				m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[1] + fCha;
		}
		else
		{
			fOtherReq = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1];//t4
			fOtherFreq = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[0];//t2
			float nFeq1 = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[0];//t1
// 			if (fReq > fOtherReq)//不能大于t4
// 			{
// 				fReq = fOtherReq;
// 			}
			if (fReq < fOtherFreq) //不能小于t2
			{
				fReq = fOtherFreq;
			}
			if (fReq < 0)
			{
				fReq = 0;
			}
			//赋值t3
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1] = fReq;
			fCha = fOtherFreq - nFeq1;
			//重新计算t4
			m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[1]
				= m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[1] + fCha;
		}
	}

	//重新计算平均波速
	//距离差
	float fDistance = m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1] - m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[0];
	float ft = 0;//时间差
	if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		ft = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[1].ft[0] -
			m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).WA_Info[0].ft[0];
		if (ft == 0)
		{
			ft = 1;
		}
		int nSpeed = int((float)fDistance * 1000 / ft);
		m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).nWaveSpeed = nSpeed;
	}
	else
	{
		ft = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[1].ft[0]
			- m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).WA_Info[0].ft[0];
		if (ft == 0)
		{
			ft = 1;
		}
		int nSpeed = int((float)fDistance * 1000 / ft);
		m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).nWaveSpeed = nSpeed;
	}
}

//获取鼠标位置波速
int CDrawWave::GetMouseWaveSpeed(CPoint pt)
{
	if (pt.x <= m_nToLeft)
	{
		pt.x = m_nToLeft + 1;
	}
	int nPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos;

	DT56_HAM_INFO Ham;
	DT56_PILE_INFO Pile_Info;
	Pile_Info = m_pData->m_vecPile.at(m_pData->m_nSelPileNo);
	if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		Ham = m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo);
	}
	else
	{
		Ham = m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo);
	}
	int nSpeed = (int)(double(2.0 * Ham.fPileLen * g_nFrq[Pile_Info.sCaiYangFreq]) / (nPos - Ham.sPileTopPos));
	nSpeed = nSpeed > 10000 ? 10000 : nSpeed;
	nSpeed = nSpeed < 0 ? 0 : nSpeed;


	m_pData->SetPileLSpeed(nSpeed, m_pData->m_nSelPileNo, m_pData->m_nSelHamNo);
// 	if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
// 	{
// 		m_pData->m_vecAvgHam.at(m_pData->m_nSelPileNo).nWaveSpeed = nSpeed;
// 	}
// 	else
// 	{
// 		m_pData->m_vvecHam[m_pData->m_nSelPileNo].at(m_pData->m_nSelHamNo).nWaveSpeed = nSpeed;
// 	}
	return nSpeed;
}

BOOL CDrawWave::GetDefectPos(CPoint pt, DEFECT_INFO &DefectInfo)
{
	if (g_WaveOperate == WAVE_OPERATE_1)
	{
//////////////////////////////////////
		short  nCaiYang = 0;
		int		nPileTopPos = 0;
		int		nSpeed = 0;
		float	fPileLen = 0;
		int		nPos = int(double(pt.x - m_nToLeft) / m_dXGap - m_nPilePos + m_nHPos);

		//桩顶到桩底实际点数
		if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen;
			nPileTopPos = m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].sPileTopPos;
			fPileLen = m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen;
			nCaiYang = m_pData->m_vecPile[m_pData->m_nSelPileNo].sCaiYangFreq;
			nSpeed = (int)(double(2.0 * fPileLen * g_nFrq[nCaiYang]) / nPos);
		}
		else
		{
			nPileTopPos = m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].sPileTopPos;
			fPileLen = m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen;
			nCaiYang = m_pData->m_vecPile[m_pData->m_nSelPileNo].sCaiYangFreq;
			nSpeed = (int)(double(2.0 * fPileLen * g_nFrq[nCaiYang]) / nPos);
		}
		
		DefectInfo.nWaveSpeed = nSpeed;
		DefectInfo.nDefectPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos;
//////////////////////////////////////

		DefectInfo.fDefectLen = float((double(pt.x - m_nToLeft + 1) / m_dXGap - m_nPilePos + m_nHPos) * m_dGap);
		DefectInfo.nDefectPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos;
	}
	else if (g_WaveOperate == WAVE_OPERATE_2)
	{
		short  nCaiYang = 0;
		int		nPileTopPos = 0;
		int		nSpeed = 0;
		float	fPileLen = 0;
		int		nPos = int(double(pt.x - m_nToLeft) / m_dXGap - m_nPilePos + m_nHPos);

		//桩顶到桩底实际点数
		if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
		{
			m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen;
			nPileTopPos = m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].sPileTopPos;
			fPileLen = m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen;
			nCaiYang = m_pData->m_vecPile[m_pData->m_nSelPileNo].sCaiYangFreq;
			nSpeed = (int)(double(2.0 * fPileLen * g_nFrq[nCaiYang]) / nPos);
		}
		else
		{
			nPileTopPos = m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].sPileTopPos;
			fPileLen = m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen;
			nCaiYang = m_pData->m_vecPile[m_pData->m_nSelPileNo].sCaiYangFreq;
			nSpeed = (int)(double(2.0 * fPileLen * g_nFrq[nCaiYang]) / nPos);
		}

		DefectInfo.nWaveSpeed = nSpeed;
		DefectInfo.nDefectPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos;

 		DefectInfo.fDefectLen = float((double(pt.x - m_nToLeft + 1) / m_dXGap - m_nPilePos + m_nHPos2) * m_dGap);
 		DefectInfo.nDefectPos = int(double(pt.x - m_nToLeft) / m_dXGap) + m_nHPos2;
	}

	DefectInfo.nPileBottm = m_nPileBottom;
	DefectInfo.nPileTop = m_nPilePos;
	if (DefectInfo.nDefectPos  > m_nPileBottom || DefectInfo.nDefectPos  < m_nPilePos)
	{
		return FALSE;
	}
	return TRUE;
}

BOOL CDrawWave::GetNormalDefectPos(CPoint pt, DEFECT_INFO &DefectInfo)
{
	int nT1T2Gap = m_nT_PosX[2] - m_nT_PosX[1];
	if (m_pData->m_nSelHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		DefectInfo.fDefectLen = float(pt.x - m_nT_PosX[1])*(
			m_pData->m_vecAvgHam[m_pData->m_nSelPileNo].fPileLen
			- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
			+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
		DefectInfo.nDefectPos = pt.x;
		DefectInfo.nPileBottm = m_nPileBottom;
		DefectInfo.nPileTop = m_nPilePos;			
	}
	else
	{
		DefectInfo.fDefectLen = float(pt.x - m_nT_PosX[1])*(
			m_pData->m_vvecHam[m_pData->m_nSelPileNo][m_pData->m_nSelHamNo].fPileLen
			- m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1]) / nT1T2Gap
			+ m_pData->m_vecPile[m_pData->m_nSelPileNo].fSensorH[1];
		DefectInfo.nDefectPos = pt.x;
		DefectInfo.nPileBottm = m_nPileBottom;
		DefectInfo.nPileTop = m_nPilePos;
	}
	return TRUE;
}

void CDrawWave::SetDefect(CDC *pDc, CRect rt, char Defect_Type, BOOL bDir)
{
	COLORREF clGray = RGB(128, 138, 135);
	COLORREF clWit = RGB(255, 255, 255);
	COLORREF clBlk = RGB(255, 255, 255);

	int nVal = 0;
	int nW = 0;
	if (bDir) //横向
	{
		nVal = rt.Height();
		nW = rt.Width();
	}
	else //纵向
	{
		nVal = rt.Width();
		nW = rt.Height();
	}
	
	CRect rtSec = rt;
	CPen pen, *pOldPen = NULL;
	switch (Defect_Type)
	{
	case SuoJing:
		pDc->FillSolidRect(rtSec, clWit);
		if (bDir)
		{
			rtSec.top = rt.top + nVal / 6;
			rtSec.bottom = rt.bottom - nVal / 6;
		}
		else
		{
			rtSec.left = rt.left + nVal / 6;
			rtSec.right = rt.right - nVal / 6;
		}
		pDc->FillSolidRect(rtSec, clGray);
		break;
	case QueXian:
		pen.CreatePen(PS_SOLID, 2, clWit);
		pOldPen = pDc->SelectObject(&pen);
		if (bDir)
		{
			pDc->MoveTo(rtSec.right, rtSec.top + nVal / 6);
			pDc->LineTo(rtSec.left, rtSec.bottom - nVal / 6);

			pDc->MoveTo(rtSec.left, rtSec.top + nVal / 6);
			pDc->LineTo(rtSec.right, rtSec.bottom - nVal / 6);
		}
		else
		{
			pDc->MoveTo(rtSec.right - nVal / 6, rtSec.top);
			pDc->LineTo(rtSec.left + nVal / 6, rtSec.bottom);

			pDc->MoveTo(rtSec.left + nVal / 6, rtSec.top);
			pDc->LineTo(rtSec.right - nVal / 6, rtSec.bottom);
		}	
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
		break;
	case LiXi:
		pen.CreatePen(PS_DOT, 1, clWit);
		pOldPen = pDc->SelectObject(&pen);
		if (bDir)
		{
			int nWid = rtSec.Width();
			int nPos = nW / 3;
			for (int i = 0; i < rtSec.Width(); i += nPos)
			{
				pDc->MoveTo(rtSec.left + i, rtSec.top + nVal / 6);
				pDc->LineTo(rtSec.left + i, rtSec.bottom - nVal / 6);
			}
		}
		else
		{
			int nWid = rtSec.Height();
			int nPos = nW / 3;
			for (int i = 0; i < rtSec.Height(); i += nPos)
			{
				pDc->MoveTo(rtSec.left + nVal / 6, rtSec.top + i);
				pDc->LineTo(rtSec.right - nVal / 6, rtSec.top + i);
			}
		}
		
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
		break;
	case DuanLie:
		if (bDir)
		{
			rtSec.left += nW / 6;
			rtSec.right -= nW / 6;
		}
		else
		{
			rtSec.top += nW / 6;
			rtSec.bottom -= nW / 6;
		}
		pDc->FillSolidRect(rtSec, clWit);
		break;
	case LieWen:
		pen.CreatePen(PS_SOLID, 1, clWit);
		pOldPen = pDc->SelectObject(&pen);
		nW /= 2;
		for (int i = 0; i < 3; ++i)
		{
			if (bDir)
			{
				pDc->MoveTo(rtSec.left + i * nW, rtSec.top + nVal / 8 * (i + 1));
				pDc->LineTo(rtSec.left + i * nW, rtSec.top + nVal / 2 + nVal / 8 * (i + 1));
			}
			else
			{
				pDc->MoveTo(rtSec.left + nVal / 8 * (i + 1), rtSec.top + i * nW);
				pDc->LineTo(rtSec.left + nVal / 2 + nVal / 8 * (i + 1), rtSec.top + i * nW);
			}
		}
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
		break;
	case KuoJing:
		if (bDir)
		{
			int nHid = nVal / 6;
			rtSec.top -= nHid;
			rtSec.bottom += nHid;
		}
		else
		{
			int nHid = nVal / 6;
			rtSec.left -= nHid;
			rtSec.right += nHid;
		}
		pDc->FillSolidRect(rtSec, clGray);
		break;
	case JiaNi:
		pen.CreatePen(PS_SOLID, 3, clWit);
		pOldPen = pDc->SelectObject(&pen);
		nVal = (nVal - 6) / 3;
		if (bDir)
		{
			pDc->MoveTo(rtSec.left, rtSec.top + nVal);
			pDc->LineTo(rtSec.right, rtSec.top + nVal);

// 			pDc->MoveTo(rtSec.left, rtSec.top + nVal * 2 + 3);
// 			pDc->LineTo(rtSec.right, rtSec.top + nVal * 2 + 3);
			pDc->MoveTo(rtSec.left, rtSec.bottom - nVal);
			pDc->LineTo(rtSec.right, rtSec.bottom - nVal);
		}
		else
		{
			pDc->MoveTo(rtSec.left + nVal, rtSec.top);
			pDc->LineTo(rtSec.left + nVal, rtSec.bottom);

			pDc->MoveTo(rtSec.left + nVal * 2 + 3, rtSec.top);
			pDc->LineTo(rtSec.left + nVal * 2 + 3, rtSec.bottom);
		}
		pDc->SelectObject(pOldPen);
		pen.DeleteObject();
		break;
	case JieZhuang:
		if (bDir)
		{
			rtSec.top += nVal / 4;
			rtSec.bottom -= nVal / 4;
		}
		else
		{
			rtSec.left += nVal / 4;
			rtSec.right -= nVal / 4;
		}
		pDc->FillSolidRect(rtSec, clWit);
		break;
	default:
		break;
	}
}

//设置频峰
BOOL CDrawWave::SetFreqTop(CPoint pt, int nNo)
{
	if (pt.x < m_nToLeft)
	{
		pt.x = m_nToLeft;
	}
	if (pt.x > m_rtWave.right - 3 * m_nToLeft)
	{
		pt.x = m_rtWave.right - 3 * m_nToLeft;
	}
	int nFrq = int(double((pt.x - m_nToLeft) / m_dXgpFreq) * m_nFrqPre);
	BOOL bRes = m_pData->SetFreqTop(nFrq, nNo);
	return bRes;
}

//取消频峰
void CDrawWave::ClearFreqTop(CPoint pt, int nNo)
{
	if (pt.x < m_nToLeft)
	{
		return ;
	}
	if (pt.x > m_rtWave.right - 3 * m_nToLeft)
	{
		return ;
	}
	int nFrq = int(double((pt.x - m_nToLeft) / m_dXgpFreq) * m_nFrqPre);
	m_pData->ClearFreqTop(nFrq, nNo);
}

//查找频率
void CDrawWave::SecrchFreq(int nBeginF, int nEndF, int nLimit, int nCnt)
{
	if (nBeginF >= nEndF)
	{
		return;
	}
	m_pData->SecrchFreq(nBeginF, nEndF, nLimit, nCnt, m_nFrqPre);
}

//生成图片
void CDrawWave::CreatePic(CDC *pDC, CRect rt, int nPileNo, int nHamNo)
{
	DT56_PILE_INFO Pile_Info;
	DT56_HAM_INFO Ham_Info;
	Pile_Info = m_pData->m_vecPile.at(nPileNo);
	if (nHamNo == AVG_WAVE_NO || g_WaveType == Ave_Wave)
	{
		Ham_Info = m_pData->m_vecAvgHam.at(nHamNo);
	}
	else
	{
		Ham_Info = m_pData->m_vvecHam[nPileNo].at(nHamNo);
	}

	//画波形和桩
	DrawPrintWaveInfoPic(pDC, Pile_Info, Ham_Info, nPileNo, nHamNo, rt);
	DrawPrintPileInfoPic(pDC, Pile_Info, Ham_Info, nPileNo, nHamNo, rt);
}